diff options
| author | Eduard Zingerman <[email protected]> | 2024-12-12 07:07:10 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2024-12-12 19:37:19 +0000 |
| commit | ac6542ad92759cda383ad62b4e4cbfc28136abc1 (patch) | |
| tree | 8466ba59d213014cd67f6e9403a4713bdf0f4769 /tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c | |
| parent | bpf: Fix theoretical prog_array UAF in __uprobe_perf_func() (diff) | |
| download | kernel-ac6542ad92759cda383ad62b4e4cbfc28136abc1.tar.gz kernel-ac6542ad92759cda383ad62b4e4cbfc28136abc1.zip | |
bpf: fix null dereference when computing changes_pkt_data of prog w/o subprogs
bpf_prog_aux->func field might be NULL if program does not have
subprograms except for main sub-program. The fixed commit does
bpf_prog_aux->func access unconditionally, which might lead to null
pointer dereference.
The bug could be triggered by replacing the following BPF program:
SEC("tc")
int main_changes(struct __sk_buff *sk)
{
bpf_skb_pull_data(sk, 0);
return 0;
}
With the following BPF program:
SEC("freplace")
long changes_pkt_data(struct __sk_buff *sk)
{
return bpf_skb_pull_data(sk, 0);
}
bpf_prog_aux instance itself represents the main sub-program,
use this property to fix the bug.
Fixes: 81f6d0530ba0 ("bpf: check changes_pkt_data property for extension programs")
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Eduard Zingerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c')
0 files changed, 0 insertions, 0 deletions
