diff options
| author | Jinghao Jia <[email protected]> | 2023-09-17 21:42:20 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2023-09-21 21:32:47 +0000 |
| commit | 9220c3ef6fefbf18f24aeedb1142a642b3de0596 (patch) | |
| tree | ac83062572f63b2577f6777d8fefd12828e4e2a9 /tools/lib/bpf/elf.c | |
| parent | samples/bpf: syscall_tp_user: Rename num_progs into nr_tests (diff) | |
| download | kernel-9220c3ef6fefbf18f24aeedb1142a642b3de0596.tar.gz kernel-9220c3ef6fefbf18f24aeedb1142a642b3de0596.zip | |
samples/bpf: syscall_tp_user: Fix array out-of-bound access
Commit 06744f24696e ("samples/bpf: Add openat2() enter/exit tracepoint
to syscall_tp sample") added two more eBPF programs to support the
openat2() syscall. However, it did not increase the size of the array
that holds the corresponding bpf_links. This leads to an out-of-bound
access on that array in the bpf_object__for_each_program loop and could
corrupt other variables on the stack. On our testing QEMU, it corrupts
the map1_fds array and causes the sample to fail:
# ./syscall_tp
prog #0: map ids 4 5
verify map:4 val: 5
map_lookup failed: Bad file descriptor
Dynamically allocate the array based on the number of programs reported
by libbpf to prevent similar inconsistencies in the future
Fixes: 06744f24696e ("samples/bpf: Add openat2() enter/exit tracepoint to syscall_tp sample")
Signed-off-by: Jinghao Jia <[email protected]>
Signed-off-by: Ruowen Qin <[email protected]>
Signed-off-by: Jinghao Jia <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/lib/bpf/elf.c')
0 files changed, 0 insertions, 0 deletions
