iovisor / bpf-fuzzer

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

Problem during the make all step #12

Open 1nd0 opened 5 years ago

1nd0 commented 5 years ago

I am running into the following issue when doing the make process.

make[1]: Entering directory /home/vagrant/net-next' CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh DESCEND objtool make[5]: *** No rule to make targetkernel/bpf/linux_hook.i'. Stop. make[4]: [__build] Error 2 make[3]: [kernel/bpf] Error 2 make[2]: [kernel] Error 2 make[1]: [sub-make] Error 2 make[1]: Leaving directory `/home/vagrant/net-next' make: *** [test_hook] Error 2

yonghong-song commented 5 years ago

@1nd0 could you help debug this a little bit further?

1nd0 commented 5 years ago

@yonghong-song I sure can what information would you like me to provide.

yonghong-song commented 5 years ago

I did not look at the issue yet. Just to find how to fix the issue you have.

1nd0 commented 5 years ago

Ill dig into net-next to see if that is where the issue is. I am guessing things have changed a bit.

1nd0 commented 5 years ago

It looks like in your make file you are doing

cd $(KERNEL_TREE_ROOT); make HOSTCC=clang CC=clang kernel/bpf/verifier.i kernel/bpf/linux_hook.i

This is causing make to use the make file in the net-next dir try to build the linux hook but it doesnt have any instructions on how to build it.

1nd0 commented 5 years ago

@yonghong-song Do you know what version of the kernel you where using the tool on ?

yonghong-song commented 5 years ago

I have tried very early version around 4.6, I think. But I think it does not make sense to go back at this stage. If you are interested, feel free to look at the new kernel versions. It is possible that some new hooks need to be added.

1nd0 commented 5 years ago

@yonghong-song So we fixed the initial issue by hard copying the linux_hook.c file into the net_next/kernel/bpf/ folder now we are running into issues building the test_verifier. looks like during the make is trying to call ARG_PTR_TO_STACK that was renamed quite awhile ago.

yonghong-song commented 5 years ago

Thanks for improving this. I indeed have not worked on this for quite a while.

AzadaShams commented 4 years ago

I am also getting a similar error running the Makefile through "make all " command.

cd /home/azada/net-next2/net-next; make HOSTCC=clang CC=clang kernel/bpf/verifier.i kernel/bpf/linux_hook.i make[1]: Entering directory '/home/azada/net-next2/net-next' Compiler lacks asm-goto support. arch/x86/Makefile:302: recipe for target 'checkbin' failed make[1]: [checkbin] Error 1 make[1]: Leaving directory '/home/azada/net-next2/net-next' Makefile:37: recipe for target 'test_hook' failed make: [test_hook] Error 2 I am using Kernel version 4.15. What is the solution? could someone please reply it as soon as possible!

yonghong-song commented 4 years ago

For

 Compiler lacks asm-goto support.

error message, could you try clang9 which has asm goto support?

PavithraKrishnaA commented 4 years ago

@yonghong-song : Thanks , yes upgrading to clang 9 had solved our issue of asm goto . Now we are stuck with the same error mentioned at the beginning of this issue . And even hardcopying (which i believe is creating a hard link) does not solve the issue . Could you please help with what can be done

yonghong-song commented 4 years ago

The error mostly due to kernel code change. So some hook change might be needed for your 4.15 kernel as kernel verifier change heavily affects this.

PavithraKrishnaA commented 4 years ago

Thanks I am looking into it now , @1nd0 : Could you please tell which kernel version you used and does hard copying mean making a copy of the file linux hook .c into the mentioned path ? And does it mean I have to skip certain lines in existing Makefile? Could you please elaborate ?

PavithraKrishnaA commented 4 years ago

@yonghong-song : Now i believe that i fixed the changes needed in test verifier . And it compiles.But i am getting undefined references during linking for the ones in verifier.c .Could you please point out if i have to add the definitions in linux hook .c (or) am i doing something wrong with the previous steps

yonghong-song commented 4 years ago

I guess, you will have to add some missing hooks. Some newer kernels will have additional hooks which need to be implemented.

sanjit-bhat commented 3 years ago

Re: the original question, the Linux developers changed the kernel build system for single target builds. With their change, things like make kernel/bpf/verifier.i won't work by default. See this discussion on the kernel mailing list for more details.

As a workaround, you have to add single target builds to the obj-y or obj-m variables in the Makefiles. After that, the above make command should work after re-generating the config files. Here's my diff:


--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y := core.o
+obj-y := core.o verifier.o linux_hook.o
 CFLAGS_core.o += $(call cc-disable-warning, override-init)

 obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o```