From 5273c61cd84fb5db4bd4c97509f60511c7a9bb6d Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Tue, 12 May 2020 23:19:51 +0200 Subject: Darwin tests: grep --binary-files=text for laf-intel and skipping of unittests --- GNUmakefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index d3e9275c..95bc1072 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -252,7 +252,7 @@ help: @echo "deepclean: cleans everything including downloads" @echo "code-format: format the code, do this before you commit and send a PR please!" @echo "tests: this runs the test framework. It is more catered for the developers, but if you run into problems this helps pinpointing the problem" - @echo "unit: perform unit tests (based on cmocka)" + @echo "unit: perform unit tests (based on cmocka and GNU linker)" @echo "document: creates afl-fuzz-document which will only do one run and save all manipulated inputs into out/queue/mutations" @echo "help: shows these build options :-)" @echo "==========================================" @@ -385,8 +385,17 @@ unit_preallocable: test/unittests/unit_preallocable.o unit_clean: @rm -f ./test/unittests/unit_preallocable ./test/unittests/unit_list ./test/unittests/unit_maybe_alloc test/unittests/*.o +ifneq "$(shell uname)" "Darwin" + unit: unit_maybe_alloc unit_preallocable unit_list unit_clean +else + +unit: + @echo [-] unit tests are skipped on Darwin \(lacks GNU linker feature --wrap\) + +endif + code-format: ./.custom-format.py -i src/*.c ./.custom-format.py -i include/*.h -- cgit 1.4.1 From c384a17b4181553d9e7c56fbafd6c8e934e6beed Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Wed, 13 May 2020 16:42:20 +0000 Subject: GNUmakefile: add paths /usr/local/... for OpenBSD, add check for ASAN --- GNUmakefile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index 95bc1072..390c4cfa 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -89,6 +89,11 @@ override CFLAGS += -Wall -g -Wno-pointer-sign -Wmissing-declarations\ -I include/ -Werror -DAFL_PATH=\"$(HELPER_PATH)\" \ -DBIN_PATH=\"$(BIN_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\" +ifeq "$(shell uname -s)" "OpenBSD" + override CFLAGS += -I /usr/local/include/ + LDFLAGS += -L /usr/local/lib/ +endif + AFL_FUZZ_FILES = $(wildcard src/afl-fuzz*.c) ifneq "$(shell command -v python3m 2>/dev/null)" "" @@ -200,13 +205,15 @@ ifeq "$(shell svn proplist . 2>/dev/null && echo 1 || echo 0)" "1" IN_REPO=1 endif -ASAN_CFLAGS=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer -ASAN_LDFLAGS=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer +ifeq "$(shell echo 'int main() { return 0;}' | $(CC) $(CFLAGS) -fsanitize=address -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" + ASAN_CFLAGS=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer + ASAN_LDFLAGS=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer +endif ifdef ASAN_BUILD - $(info Compiling ASAN version of binaries) - CFLAGS+=$(ASAN_CFLAGS) - LDFLAGS+=$(ASAN_LDFLAGS) + $(info Compiling ASAN version of binaries) + CFLAGS+=$(ASAN_CFLAGS) + LDFLAGS+=$(ASAN_LDFLAGS) endif ifeq "$(shell echo '$(HASH)include @$(HASH)include @int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" -- cgit 1.4.1 From b6be9060826a8617378e7ec1ee128057b51d8f85 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Wed, 13 May 2020 17:03:59 +0200 Subject: GNUmakefile: avoid tabs --- GNUmakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index 390c4cfa..eefba857 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -211,9 +211,9 @@ ifeq "$(shell echo 'int main() { return 0;}' | $(CC) $(CFLAGS) -fsanitize=addres endif ifdef ASAN_BUILD - $(info Compiling ASAN version of binaries) - CFLAGS+=$(ASAN_CFLAGS) - LDFLAGS+=$(ASAN_LDFLAGS) + $(info Compiling ASAN version of binaries) + CFLAGS+=$(ASAN_CFLAGS) + LDFLAGS+=$(ASAN_LDFLAGS) endif ifeq "$(shell echo '$(HASH)include @$(HASH)include @int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" -- cgit 1.4.1 From 8cc54424019d64d5dabd5c53277ddb09542b5a1c Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 13 May 2020 18:20:06 +0200 Subject: fix GNUmakefile --- GNUmakefile | 6 +++--- src/afl-fuzz-init.c | 18 ++++++++++-------- src/afl-fuzz-run.c | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 11 deletions(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index eefba857..00b61cd2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -211,9 +211,9 @@ ifeq "$(shell echo 'int main() { return 0;}' | $(CC) $(CFLAGS) -fsanitize=addres endif ifdef ASAN_BUILD - $(info Compiling ASAN version of binaries) - CFLAGS+=$(ASAN_CFLAGS) - LDFLAGS+=$(ASAN_LDFLAGS) + $(info Compiling ASAN version of binaries) + CFLAGS+=$(ASAN_CFLAGS) + LDFLAGS+=$(ASAN_LDFLAGS) endif ifeq "$(shell echo '$(HASH)include @$(HASH)include @int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index d468f2c8..9b7ead29 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -1383,16 +1383,18 @@ void setup_dirs_fds(afl_state_t *afl) { } -/* - if (afl->is_master) { + /* + if (afl->is_master) { - u8 *x = alloc_printf("%s/is_master", afl->sync_dir); - int fd = open(x, O_CREAT | O_RDWR, 0644); - if (fd < 0) FATAL("cannot create %s", x); - close(fd); + u8 *x = alloc_printf("%s/%s/is_master", afl->sync_dir, afl->sync_id); + int fd = open(x, O_CREAT | O_RDWR, 0644); + if (fd < 0) FATAL("cannot create %s", x); + free(x); + close(fd); - } -*/ + } + + */ if (mkdir(afl->out_dir, 0700)) { diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c index d9adb792..bbcd9a99 100644 --- a/src/afl-fuzz-run.c +++ b/src/afl-fuzz-run.c @@ -401,6 +401,20 @@ void sync_fuzzers(afl_state_t *afl) { } + /* + // a slave only syncs from a master, a master syncs from everyone + if (likely(afl->is_slave)) { + + u8 x = alloc_printf("%s/%s/is_master", afl->sync_dir, sd_ent->d_name); + int res = access(x, F_OK); + free(x); + if (res != 0) + continue; + + } + + */ + /* Skip anything that doesn't have a queue/ subdirectory. */ qd_path = alloc_printf("%s/%s/queue", afl->sync_dir, sd_ent->d_name); -- cgit 1.4.1 From 4e192db13caa8a6c5234c282986f91c8aaf49e20 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 13 May 2020 18:24:01 +0200 Subject: better clean --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index 00b61cd2..6fad5f92 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -455,7 +455,7 @@ all_done: test_build .NOTPARALLEL: clean all clean: - rm -f $(PROGS) libradamsa.so afl-fuzz-document afl-as as afl-g++ afl-clang afl-clang++ *.o src/*.o *~ a.out core core.[1-9][0-9]* *.stackdump .test .test1 .test2 test-instr .test-instr0 .test-instr1 afl-qemu-trace afl-gcc-fast afl-gcc-pass.so afl-gcc-rt.o afl-g++-fast ld *.so *.8 test/unittests/*.o test/unittests/unit_maybe_alloc test/unittests/preallocable + rm -f $(PROGS) libradamsa.so afl-fuzz-document afl-as as afl-g++ afl-clang afl-clang++ *.o src/*.o *~ a.out core core.[1-9][0-9]* *.stackdump .test .test1 .test2 test-instr .test-instr0 .test-instr1 afl-qemu-trace afl-gcc-fast afl-gcc-pass.so afl-gcc-rt.o afl-g++-fast ld *.so *.8 test/unittests/*.o test/unittests/unit_maybe_alloc test/unittests/preallocable .afl-* rm -rf out_dir qemu_mode/qemu-3.1.1 *.dSYM */*.dSYM -$(MAKE) -C llvm_mode clean -$(MAKE) -C gcc_plugin clean -- cgit 1.4.1 From fa20eb1de7544fb2213917dee830cb3ea11d7f16 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Thu, 14 May 2020 18:47:44 +0200 Subject: GNUmakefile: add standard path for NetBSD, test for git and svn before use --- GNUmakefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index 6fad5f92..fd43e11a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -94,6 +94,11 @@ ifeq "$(shell uname -s)" "OpenBSD" LDFLAGS += -L /usr/local/lib/ endif +ifeq "$(shell uname -s)" "NetBSD" + override CFLAGS += -I /usr/pkg/include/ + LDFLAGS += -L /usr/pkg/lib/ +endif + AFL_FUZZ_FILES = $(wildcard src/afl-fuzz*.c) ifneq "$(shell command -v python3m 2>/dev/null)" "" @@ -198,10 +203,10 @@ ifdef NO_PYTHON endif IN_REPO=0 -ifeq "$(shell git status >/dev/null 2>&1 && echo 1 || echo 0)" "1" +ifeq "$(shell command -v git && git status >/dev/null 2>&1 && echo 1 || echo 0)" "1" IN_REPO=1 endif -ifeq "$(shell svn proplist . 2>/dev/null && echo 1 || echo 0)" "1" +ifeq "$(shell command -v svn && svn proplist . 2>/dev/null && echo 1 || echo 0)" "1" IN_REPO=1 endif -- cgit 1.4.1 From 867f948bb22688bc2ca250f3cc28402662cc1b0c Mon Sep 17 00:00:00 2001 From: Ruben ten Hove Date: Thu, 14 May 2020 16:56:40 +0200 Subject: create temp symlink to python3 for qemu mode if python isn't found --- CONTRIBUTING.md | 5 +++++ GNUmakefile | 2 +- qemu_mode/build_qemu_support.sh | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'GNUmakefile') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90049432..bd0a0ed8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,3 +20,8 @@ No camel case at all and use the AFL's macros wherever possible Remember that AFLplusplus has to build and run on many platforms, so generalize your Makefiles (or your patches to our pre-existing Makefiles) to be as much generic as possible. + + +# Local testing + +To try diff --git a/GNUmakefile b/GNUmakefile index fd43e11a..8bdd642e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -105,7 +105,7 @@ ifneq "$(shell command -v python3m 2>/dev/null)" "" ifneq "$(shell command -v python3m-config 2>/dev/null)" "" PYTHON_INCLUDE ?= $(shell python3m-config --includes) PYTHON_VERSION ?= $(strip $(shell python3m --version 2>&1)) - # Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag. + # Starting with python3.8, we need to pass the `embed` flag. Earlier versions didn't know this flag. ifeq "$(shell python3m-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1" PYTHON_LIB ?= $(shell python3m-config --libs --embed --ldflags) else diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh index bd18927f..983373ce 100755 --- a/qemu_mode/build_qemu_support.sh +++ b/qemu_mode/build_qemu_support.sh @@ -63,7 +63,7 @@ if [ ! -f "../afl-showmap" ]; then fi PREREQ_NOTFOUND= -for i in libtool wget python automake autoconf sha384sum bison flex iconv patch pkg-config; do +for i in libtool wget automake autoconf sha384sum bison flex iconv patch pkg-config; do T=`command -v "$i" 2>/dev/null` @@ -76,6 +76,18 @@ for i in libtool wget python automake autoconf sha384sum bison flex iconv patch done +PYTHON_TEMP_SYMLINK=0 +if ! command -v python 1>/dev/null; then + if command -v python3 1>/dev/null; then + echo "[*] 'python' not found. 'python3' was found. Creating temporary symlink." + update-alternatives --install /usr/bin/python python "$(command -v python3)" 0 1>/dev/null + PYTHON_TEMP_SYMLINK=1 + else + echo "[-] Error: 'python' not found, please install using 'sudo apt install python3'." + PREREQ_NOTFOUND=1 + fi +fi + if [ ! -d "/usr/include/glib-2.0/" -a ! -d "/usr/local/include/glib-2.0/" ]; then echo "[-] Error: devel version of 'glib2' not found, please install first." @@ -279,6 +291,12 @@ echo "[+] Building libcompcov ..." make -C libcompcov && echo "[+] libcompcov ready" echo "[+] Building unsigaction ..." make -C unsigaction && echo "[+] unsigaction ready" + +if [ "PYTHON_TEMP_SYMLINK" = "1" ]; then + echo "[*] Removing temporary symlink for 'python'" + update-alternatives --remove python /usr/bin/python +fi + echo "[+] All done for qemu_mode, enjoy!" exit 0 -- cgit 1.4.1 From a55e26959beee4d9c0a6de795a8f7bc9b6ae979b Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Fri, 15 May 2020 01:31:02 +0200 Subject: fixed recursive clean --- GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile index 8bdd642e..7d9e6d83 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -203,10 +203,10 @@ ifdef NO_PYTHON endif IN_REPO=0 -ifeq "$(shell command -v git && git status >/dev/null 2>&1 && echo 1 || echo 0)" "1" +ifeq "$(shell command -v git >/dev/null && git status >/dev/null 2>&1 && echo 1 || echo 0)" "1" IN_REPO=1 endif -ifeq "$(shell command -v svn && svn proplist . 2>/dev/null && echo 1 || echo 0)" "1" +ifeq "$(shell command -v svn >/dev/null && svn proplist . 2>/dev/null && echo 1 || echo 0)" "1" IN_REPO=1 endif -- cgit 1.4.1