mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-28 20:29:07 +08:00
tests: move the fuzzer upstream
It should make it easier to start using CFLite or something like that to fuzz libbpf without getting pointless CVEs :-) More importantly, now it's possible to build the fuzzer by just cloning the repository, installing clang and running `./scripts/build-fuzzers.h`: ``` git clone https://github.com/libbpf/libbpf ./scripts/build-fuzzers.h unzip -d CORPUS fuzz/bpf-object-fuzzer_seed_corpus.zip ./out/bpf-object-fuzzer CORPUS ``` It should make it easier (for me at least) to report some elfutils bugs because they are much easier to reproduce manually now.
This commit is contained in:
committed by
Andrii Nakryiko
parent
3febb8a165
commit
393a058d06
23
fuzz/bpf-object-fuzzer.c
Normal file
23
fuzz/bpf-object-fuzzer.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "libbpf.h"
|
||||
|
||||
static int libbpf_print_fn(enum libbpf_print_level level, const char *format, va_list args)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
struct bpf_object *obj = NULL;
|
||||
DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts);
|
||||
int err;
|
||||
|
||||
libbpf_set_print(libbpf_print_fn);
|
||||
|
||||
opts.object_name = "fuzz-object";
|
||||
obj = bpf_object__open_mem(data, size, &opts);
|
||||
err = libbpf_get_error(obj);
|
||||
if (err)
|
||||
return 0;
|
||||
|
||||
bpf_object__close(obj);
|
||||
return 0;
|
||||
}
|
||||
BIN
fuzz/bpf-object-fuzzer_seed_corpus.zip
Normal file
BIN
fuzz/bpf-object-fuzzer_seed_corpus.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user