]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Sanitise internal map names so they are not rejected by the kernel
authorToke Høiland-Jørgensen <toke@redhat.com>
Mon, 17 Feb 2020 17:17:01 +0000 (18:17 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 18 Feb 2020 14:34:20 +0000 (15:34 +0100)
commitfa69b12ff0d2aa70ce738200bd9f0f5a972b3a0d
tree96d646cc04e8d070610f657cb716217268e2d3d9
parenta048c96318d5242acf16f018b10375dc90caf098
libbpf: Sanitise internal map names so they are not rejected by the kernel

The kernel only accepts map names with alphanumeric characters, underscores
and periods in their name. However, the auto-generated internal map names
used by libbpf takes their prefix from the user-supplied BPF object name,
which has no such restriction. This can lead to "Invalid argument" errors
when trying to load a BPF program using global variables.

Fix this by sanitising the map names, replacing any non-allowed characters
with underscores.

Fixes: bf571d98c957 ("bpf, libbpf: support global data/bss/rodata sections")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200217171701.215215-1-toke@redhat.com
tools/lib/bpf/libbpf.c