OrangePi_CM5/tools/bpf/bpftool
Pu Lehui 8c80b2fca4 bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE
[ Upstream commit 34de8e6e0e1f66e431abf4123934a2581cb5f133 ]

When using bpftool to pin {PROG, MAP, LINK} without FILE,
segmentation fault will occur. The reson is that the lack
of FILE will cause strlen to trigger NULL pointer dereference.
The corresponding stacktrace is shown below:

do_pin
  do_pin_any
    do_pin_fd
      mount_bpffs_for_pin
        strlen(name) <- NULL pointer dereference

Fix it by adding validation to the common process.

Fixes: 75a1e792c3 ("tools: bpftool: Allow all prog/map handles for pinning objects")
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20221102084034.3342995-1-pulehui@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-16 09:57:08 +01:00
..
Documentation bpftool: Remove inclusion of utilities.mak from Makefiles 2022-01-27 10:54:30 +01:00
bash-completion bpftool: Add sock_release help info for cgroup attach/prog load command 2021-06-03 09:00:51 +02:00
skeleton
.gitignore
Makefile bpftool: Remove inclusion of utilities.mak from Makefiles 2022-01-27 10:54:30 +01:00
btf.c
btf_dumper.c bpftool: Fix a wrong type cast in btf_dumper_int 2022-10-26 13:25:19 +02:00
cfg.c
cfg.h
cgroup.c bpftool: Add sock_release help info for cgroup attach/prog load command 2021-06-03 09:00:51 +02:00
common.c bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE 2022-11-16 09:57:08 +01:00
feature.c
gen.c
iter.c
jit_disasm.c bpftool: Properly close va_list 'ap' by va_end() on error 2021-07-25 14:36:21 +02:00
json_writer.c
json_writer.h
link.c
main.c bpftool: Clear errno after libcap's checks 2022-10-26 13:25:45 +02:00
main.h
map.c
map_perf_ring.c
net.c
netlink_dumper.c
netlink_dumper.h
perf.c
pids.c
prog.c bpftool: Avoid leaking the JSON writer prepared for program metadata 2021-11-18 14:04:10 +01:00
struct_ops.c
tracelog.c
xlated_dumper.c
xlated_dumper.h