iovisor / bpf-fuzzer

fuzzing framework based on libfuzzer and clang sanitizer
GNU General Public License v2.0
163 stars 19 forks source link

Problem in make test_verifier #13

Open linkeLi0421 opened 2 years ago

linkeLi0421 commented 2 years ago
/usr/bin/ld: /tmp/verifier-2b3137.o: in function `bpf_check':
/llvm/bpf-fuzzer/bld/kernel/bpf/verifier.c:2286: undefined reference to `capable'
/usr/bin/ld: /tmp/verifier-2b3137.o: in function `kmalloc':
/llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmalloc_caches'
/usr/bin/ld: /llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmem_cache_alloc_trace'
/usr/bin/ld: /tmp/verifier-2b3137.o: in function `replace_map_fd_with_map_ptr':
/llvm/bpf-fuzzer/bld/kernel/bpf/verifier.c:2044: undefined reference to `__bpf_map_get'
/usr/bin/ld: /llvm/bpf-fuzzer/bld/kernel/bpf/verifier.c:2072: undefined reference to `bpf_map_inc'
/usr/bin/ld: /tmp/verifier-2b3137.o: in function `kmalloc':
/llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmalloc_caches'
/usr/bin/ld: /llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmem_cache_alloc_trace'
/usr/bin/ld: /llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmalloc_caches'
/usr/bin/ld: /llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmem_cache_alloc_trace'
/usr/bin/ld: /tmp/linux_hook-8fd561.o: in function `kmalloc':
/llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmalloc_caches'
/usr/bin/ld: /llvm/bpf-fuzzer/bld/include/linux/slab.h:478: undefined reference to `kmem_cache_alloc_trace'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:44: test_verifier] Error 1

I try to make all the project and I use linux4.6 as linux source tree. I get this error message and can't solve it, do you have some suggestions for me? Thank you very much.

yonghong-song commented 2 years ago

I haven't touched it for a long time. You probably need to implement a bunch of dummy kernel functions like kmem_cache_alloc_trace etc to make it work. In the long run, if we could share verifier code in the user space as well, that will make fuzzing easier. But it may be difficult to do that as verifier is too tired to kernel internals.