diff --git a/README.md b/README.md index fc02a37..7a71f06 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ make headers_install ``` For above linux tree, apply the following patch so that llvm can cope with linux -inline assembly, and workaround a memory leak reporting issue. +inline assembly: ``` yhs@ubuntu:~/work/fuzzer/net-next$ git diff @@ -64,25 +64,6 @@ index c361593..cacbe0f 100644 else # This warning generated too much noise in a regular build. -diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c -index b074b23..af83c6e 100644 ---- a/kernel/bpf/verifier.c -+++ b/kernel/bpf/verifier.c -@@ -2186,6 +2186,14 @@ skip_full_check: - * bpf_ld_imm64 instructions - */ - convert_pseudo_ld_imm64(env); -+ -+#if 1 -+ /* this is a workaround for userspace verifier. -+ * in kernel, the env->prog->aux->used_maps will be -+ * freed when the map itself is freed. -+ */ -+ kfree(env->prog->aux->used_maps); -+#endif - } - - free_log_buf: yhs@ubuntu:~/work/fuzzer/net-next$ ``` diff --git a/src/helper/linux_hook.c b/src/helper/linux_hook.c index a412547..679d7f4 100644 --- a/src/helper/linux_hook.c +++ b/src/helper/linux_hook.c @@ -801,6 +801,12 @@ int bpf_prog_load(enum bpf_prog_type prog_type, if (err >= 0) { /* run eBPF verifier */ err = bpf_check(&prog, &attr); + + /* this is a workaround for userspace verifier. + * in kernel, the env->prog->aux->used_maps will be + * freed when the map itself is freed. + */ + kfree(prog->aux->used_maps); } bpf_prog_free_k(prog); return err; diff --git a/src/test/linux-samples-bpf/test_verifier.c b/src/test/linux-samples-bpf/test_verifier.c index f7dea45..4554815 100644 --- a/src/test/linux-samples-bpf/test_verifier.c +++ b/src/test/linux-samples-bpf/test_verifier.c @@ -1009,7 +1009,7 @@ static void usage(char *prog) int main(int argc, char **argv) { - if (argc > 0) { + if (argc > 1) { if (argc == 3 && strcmp(argv[1], "-g") == 0) { /* generate test cases for fuzzer, no need to run the test */ int ret;