linux-stable/tools/bpf/bpftool
Pu Lehui 34de8e6e0e bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE
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
2022-11-02 12:05:42 +01:00
..
bash-completion bpftool: Rename "bpftool feature list" into "... feature list_builtins" 2022-07-05 11:53:54 +02:00
Documentation bpf: Define new BPF_MAP_TYPE_USER_RINGBUF map type 2022-09-21 16:24:17 -07:00
skeleton bpftool: Add bpf_cookie to link output 2022-03-15 15:07:27 -07:00
.gitignore bpftool: Fix SPDX tag for Makefiles and .gitignore 2021-11-10 09:00:52 -08:00
btf.c bpftool: Fix error message of strerror 2022-09-30 15:40:46 -07:00
btf_dumper.c bpftool: Fix a wrong type cast in btf_dumper_int 2022-08-25 11:43:08 -07:00
cfg.c
cfg.h
cgroup.c bpftool: Fix wrong cgroup attach flags being assigned to effective progs 2022-09-21 10:57:12 -07:00
common.c bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE 2022-11-02 12:05:42 +01:00
feature.c bpftool: Fix a typo in a comment 2022-08-15 17:29:42 +02:00
gen.c bpftool: Fix error message of strerror 2022-09-30 15:40:46 -07:00
iter.c bpftool: Use libbpf_get_error() to check error 2021-11-14 18:38:13 -08:00
jit_disasm.c tools bpftool: Fix compilation error with new binutils 2022-08-01 15:32:46 -03:00
json_writer.c
json_writer.h
link.c bpftool: Show parameters of BPF task iterators. 2022-09-28 16:30:08 -07:00
main.c bpftool: Clear errno after libcap's checks 2022-08-15 20:37:33 +02:00
main.h bpftool: Remove attach_type_name forward declaration 2022-06-30 16:11:20 +02:00
Makefile bpftool: Complete libbfd feature detection 2022-08-10 10:44:01 -03:00
map.c bpf: Define new BPF_MAP_TYPE_USER_RINGBUF map type 2022-09-21 16:24:17 -07:00
map_perf_ring.c bpftool: Fix error message of strerror 2022-09-30 15:40:46 -07:00
net.c bpftool: use new API for attaching XDP program 2022-01-20 21:22:02 -08:00
netlink_dumper.c
netlink_dumper.h
perf.c bpftool, musl compat: Replace nftw with FTW_ACTIONRETVAL 2022-04-25 23:24:16 +02:00
pids.c Revert "bpftool: Use libbpf 1.0 API mode instead of RLIMIT_MEMLOCK" 2022-06-14 22:18:06 +02:00
prog.c bpftool: Replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE macro 2022-07-29 10:40:51 -07:00
struct_ops.c Revert "bpftool: Use libbpf 1.0 API mode instead of RLIMIT_MEMLOCK" 2022-06-14 22:18:06 +02:00
tracelog.c bpftool, musl compat: Replace sys/fcntl.h by fcntl.h 2022-04-25 23:24:28 +02:00
xlated_dumper.c bpftool: Remove usage of reallocarray() 2022-02-23 13:55:01 -08:00
xlated_dumper.h