linux-yocto/tools/bpf/bpftool
Viktor Malik 38d906f1c5 bpftool: Fix readlink usage in get_fd_type
[ Upstream commit 0053f7d39d ]

The `readlink(path, buf, sizeof(buf))` call reads at most sizeof(buf)
bytes and *does not* append null-terminator to buf. With respect to
that, fix two pieces in get_fd_type:

1. Change the truncation check to contain sizeof(buf) rather than
   sizeof(path).
2. Append null-terminator to buf.

Reported by Coverity.

Signed-off-by: Viktor Malik <vmalik@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20250129071857.75182-1-vmalik@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:42:14 +02:00
..
bash-completion
Documentation
skeleton bpftool: Fix missing pids during link show 2024-06-12 11:11:35 +02:00
.gitignore
btf_dumper.c
btf.c
cfg.c
cfg.h
cgroup.c
common.c bpftool: Fix readlink usage in get_fd_type 2025-06-04 14:42:14 +02:00
feature.c
gen.c
iter.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-06-12 11:11:38 +02:00
jit_disasm.c bpf, bpftool: Fix incorrect disasm pc 2024-12-09 10:32:07 +01:00
json_writer.c
json_writer.h
link.c
main.c
main.h bpftool: Mount bpffs on provided dir instead of parent dir 2024-06-12 11:11:38 +02:00
Makefile
map_perf_ring.c
map.c
net.c bpftool: Fix undefined behavior in qsort(NULL, 0, ...) 2024-10-10 11:57:40 +02:00
netlink_dumper.c
netlink_dumper.h
perf.c
pids.c
prog.c bpf: bpftool: Setting error code in do_loader() 2025-05-02 07:50:53 +02:00
struct_ops.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-06-12 11:11:38 +02:00
tracelog.c
xlated_dumper.c
xlated_dumper.h