linux-stable/tools/bpf/bpftool
Daniel T. Lee 96b2eb6e77 tools, bpftool: Fix struct_ops command invalid pointer free
In commit 65c9362859 ("bpftool: Add struct_ops support") a new
type of command named struct_ops has been added. This command requires
a kernel with CONFIG_DEBUG_INFO_BTF=y set and for retrieving BTF info
in bpftool, the helper get_btf_vmlinux() is used.

When running this command on kernel without BTF debug info, this will
lead to 'btf_vmlinux' variable being an invalid(error) pointer. And by
this, btf_free() causes a segfault when executing 'bpftool struct_ops'.

This commit adds pointer validation with IS_ERR not to free invalid
pointer, and this will fix the segfault issue.

Fixes: 65c9362859 ("bpftool: Add struct_ops support")
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200410020612.2930667-1-danieltimlee@gmail.com
2020-04-14 21:33:53 +02:00
..
bash-completion bpftool: Add struct_ops support 2020-03-20 15:51:35 +01:00
Documentation bpftool: Add struct_ops support 2020-03-20 15:51:35 +01:00
skeleton bpftool: Use linux/types.h from source tree for profiler build 2020-03-12 16:22:41 +01:00
.gitignore SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
btf.c bpftool: Add header guards to generated vmlinux.h 2020-03-02 16:25:14 -08:00
btf_dumper.c bpftool: Translate prog_id to its bpf prog_name 2020-03-20 15:51:35 +01:00
cfg.c tools: bpftool: teach cfg code about JMP32 2019-01-26 13:33:01 -08:00
cfg.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00
cgroup.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
common.c tools: bpftool: Restore message on failure to guess program type 2020-03-13 12:49:51 -07:00
feature.c bpftool: Make probes which emit dmesg warnings optional 2020-02-26 18:34:34 +01:00
gen.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
jit_disasm.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
json_writer.c tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
json_writer.h tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
main.c bpftool: Add struct_ops support 2020-03-20 15:51:35 +01:00
main.h bpftool: Add struct_ops support 2020-03-20 15:51:35 +01:00
Makefile tools/bpf: Move linux/types.h for selftests and bpftool 2020-03-13 20:56:34 +01:00
map.c tools: bpftool: Allow all prog/map handles for pinning objects 2020-03-13 00:24:08 +01:00
map_perf_ring.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
net.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.h tools: bpftool: dual license all files 2018-12-13 12:08:44 +01:00
perf.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
prog.c tools: bpftool: Restore message on failure to guess program type 2020-03-13 12:49:51 -07:00
struct_ops.c tools, bpftool: Fix struct_ops command invalid pointer free 2020-04-14 21:33:53 +02:00
tracelog.c tools: bpftool: add an option to prevent auto-mount of bpffs, tracefs 2018-12-18 14:47:17 +01:00
xlated_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
xlated_dumper.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00