Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer dereferencing in bpf_object__collect_prog_relos #702

Open
rish9101 opened this issue Jun 25, 2023 · 0 comments
Open

Null pointer dereferencing in bpf_object__collect_prog_relos #702

rish9101 opened this issue Jun 25, 2023 · 0 comments

Comments

@rish9101
Copy link

rish9101 commented Jun 25, 2023

I found a null pointer dereferencing bug at line 4268 in libbpf.c. This is caused due to a accessing a pointer of type Elf_Data being NULL. This holds the section data in the function and no check for it being NULL is present in bpf_object__collect_prog_relos function.
The bug is triggered by fuzzing using the harness bpf-object-fuzzer.c provided in fuzz folder.
The stack trace is attached below

#0  0x0000000000408764 in bpf_object__collect_prog_relos (obj=<optimized out>, shdr=<optimized out>, data=<optimized out>) at libbpf.c:4268
#1  bpf_object__collect_relos (obj=<optimized out>) at libbpf.c:6696
#2  bpf_object_open (path=<optimized out>, path@entry=0x0, obj_buf=<optimized out>, obj_buf_sz=<optimized out>, opts=<optimized out>) at libbpf.c:7380
#3  0x0000000000409bdb in bpf_object__open_mem (obj_buf=0x44b8c8, obj_buf_sz=0x15, opts=0x7) at libbpf.c:7415

The crashing input has been attached below.

The bug has been tested on Ubuntu 20.04, libbpf built with clang-11.
null_ptr_deref_2.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant