OpenCloudOS-Kernel/tools/lib/bpf
Quentin Monnet d77be68955 libbpf: fix string comparison for guessing eBPF program type
libbpf is able to deduce the type of a program from the name of the ELF
section in which it is located. However, the comparison is made on the
first n characters, n being determined with sizeof() applied to the
reference string (e.g. "xdp"). When such section names are supposed to
receive a suffix separated with a slash (e.g. "kprobe/"), using sizeof()
takes the final NUL character of the reference string into account,
which implies that both strings must be equal. Instead, the desired
behaviour would consist in taking the length of the string, *without*
accounting for the ending NUL character, and to make sure the reference
string is a prefix to the ELF section name.

Subtract 1 to the total size of the string for obtaining the length for
the comparison.

Fixes: 583c90097f ("libbpf: add ability to guess program type based on section name")
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-01-17 01:15:05 +01:00
..
.gitignore tools lib bpf: Change FEATURE-DUMP to FEATURE-DUMP.libbpf 2015-11-05 12:47:51 -03:00
Build bpf tools: Add bpf.c/h for common bpf operations 2015-08-07 10:16:58 -03:00
Makefile libbpf: fix Makefile exit code if libelf not found 2017-12-17 20:40:29 +01:00
bpf.c libbpf: add support for BPF_PROG_QUERY 2017-10-04 16:05:05 -07:00
bpf.h libbpf: add support for bpf_call 2017-12-17 20:34:35 +01:00
libbpf.c libbpf: fix string comparison for guessing eBPF program type 2018-01-17 01:15:05 +01:00
libbpf.h libbpf: use map_flags when creating maps 2017-10-05 21:42:28 -07:00