diff options
author | Rong Tao <rongtao@cestc.cn> | 2025-02-12 20:45:52 +0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2025-02-13 20:11:38 -0800 |
commit | a4585442ade5ac722248137dc650bff55ebb8ca0 (patch) | |
tree | e38432dea1d56451f54b8c72543bdb728c5b1022 /tools/perf/scripts/python/exported-sql-viewer.py | |
parent | 68a41544909eff32df9a84c89cd10ec328a1858c (diff) |
bpftool: Check map name length when map create
The size of struct bpf_map::name is BPF_OBJ_NAME_LEN (16).
bpf(2) {
map_create() {
bpf_obj_name_cpy(map->name, attr->map_name, sizeof(attr->map_name));
}
}
When specifying a map name using bpftool map create name, no error is
reported if the name length is greater than 15.
$ sudo bpftool map create /sys/fs/bpf/12345678901234567890 \
type array key 4 value 4 entries 5 name 12345678901234567890
Users will think that 12345678901234567890 is legal, but this name cannot
be used to index a map.
$ sudo bpftool map show name 12345678901234567890
Error: can't parse name
$ sudo bpftool map show
...
1249: array name 123456789012345 flags 0x0
key 4B value 4B max_entries 5 memlock 304B
$ sudo bpftool map show name 123456789012345
1249: array name 123456789012345 flags 0x0
key 4B value 4B max_entries 5 memlock 304B
The map name provided in the command line is truncated, but no warning is
reported. This submission checks the length of the map name.
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Link: https://lore.kernel.org/r/tencent_B44B3A95F0D7C2512DC40D831DA1FA2C9907@qq.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
0 files changed, 0 insertions, 0 deletions