This commit is contained in:
vanhauser-thc 2021-04-04 20:05:02 +02:00
parent c23183f1dc
commit 3c846859ee
11 changed files with 55 additions and 42 deletions

View File

@ -36,6 +36,11 @@ SH_PROGS = afl-plot afl-cmin afl-cmin.bash afl-whatsup afl-system-config
MANPAGES=$(foreach p, $(PROGS) $(SH_PROGS), $(p).8) afl-as.8
ASAN_OPTIONS=detect_leaks=0
SYS = $(shell uname -s)
ARCH = $(shell uname -m)
$(info [*] Compiling afl++ for OS $(SYS) on ARCH $(ARCH))
ifdef NO_SPLICING
override CFLAGS += -DNO_SPLICING
endif
@ -82,7 +87,7 @@ endif
# endif
#endif
ifneq "$(shell uname)" "Darwin"
ifneq "$(SYS)" "Darwin"
#ifeq "$(HAVE_MARCHNATIVE)" "1"
# SPECIAL_PERFORMANCE += -march=native
#endif
@ -92,7 +97,7 @@ ifneq "$(shell uname)" "Darwin"
endif
endif
ifeq "$(shell uname)" "SunOS"
ifeq "$(SYS)" "SunOS"
CFLAGS_OPT += -Wno-format-truncation
LDFLAGS = -lkstat -lrt
endif
@ -119,11 +124,10 @@ ifdef INTROSPECTION
CFLAGS_OPT += -DINTROSPECTION=1
endif
ifneq "$(shell uname -m)" "x86_64"
ifneq "$(patsubst i%86,i386,$(shell uname -m))" "i386"
ifneq "$(shell uname -m)" "amd64"
ifneq "$(shell uname -m)" "i86pc"
ifneq "$(ARCH)" "x86_64"
ifneq "$(patsubst i%86,i386,$(ARCH))" "i386"
ifneq "$(ARCH)" "amd64"
ifneq "$(ARCH)" "i86pc"
AFL_NO_X86=1
endif
endif
@ -141,27 +145,27 @@ override CFLAGS += -g -Wno-pointer-sign -Wno-variadic-macros -Wall -Wextra -Wpoi
-I include/ -DAFL_PATH=\"$(HELPER_PATH)\" \
-DBIN_PATH=\"$(BIN_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\"
ifeq "$(shell uname -s)" "FreeBSD"
ifeq "$(SYS)" "FreeBSD"
override CFLAGS += -I /usr/local/include/
LDFLAGS += -L /usr/local/lib/
endif
ifeq "$(shell uname -s)" "DragonFly"
ifeq "$(SYS)" "DragonFly"
override CFLAGS += -I /usr/local/include/
LDFLAGS += -L /usr/local/lib/
endif
ifeq "$(shell uname -s)" "OpenBSD"
ifeq "$(SYS)" "OpenBSD"
override CFLAGS += -I /usr/local/include/ -mno-retpoline
LDFLAGS += -Wl,-z,notext -L /usr/local/lib/
endif
ifeq "$(shell uname -s)" "NetBSD"
ifeq "$(SYS)" "NetBSD"
override CFLAGS += -I /usr/pkg/include/
LDFLAGS += -L /usr/pkg/lib/
endif
ifeq "$(shell uname -s)" "Haiku"
ifeq "$(SYS)" "Haiku"
SHMAT_OK=0
override CFLAGS += -DUSEMMAP=1 -Wno-error=format -fPIC
LDFLAGS += -Wno-deprecated-declarations -lgnu
@ -236,24 +240,24 @@ else
BUILD_DATE ?= $(shell date "+%Y-%m-%d")
endif
ifneq "$(filter Linux GNU%,$(shell uname))" ""
ifneq "$(filter Linux GNU%,$(SYS))" ""
ifndef DEBUG
override CFLAGS += -D_FORTIFY_SOURCE=2
endif
LDFLAGS += -ldl -lrt -lm
endif
ifneq "$(findstring FreeBSD, $(shell uname))" ""
ifneq "$(findstring FreeBSD, $(ARCH))" ""
override CFLAGS += -pthread
LDFLAGS += -lpthread
endif
ifneq "$(findstring NetBSD, $(shell uname))" ""
ifneq "$(findstring NetBSD, $(ARCH))" ""
override CFLAGS += -pthread
LDFLAGS += -lpthread
endif
ifneq "$(findstring OpenBSD, $(shell uname))" ""
ifneq "$(findstring OpenBSD, $(ARCH))" ""
override CFLAGS += -pthread
LDFLAGS += -lpthread
endif
@ -485,7 +489,7 @@ unit_clean:
@rm -f ./test/unittests/unit_preallocable ./test/unittests/unit_list ./test/unittests/unit_maybe_alloc test/unittests/*.o
.PHONY: unit
ifneq "$(shell uname)" "Darwin"
ifneq "$(ARCH)" "Darwin"
unit: unit_maybe_alloc unit_preallocable unit_list unit_clean unit_rand unit_hash
else
unit:

View File

@ -41,6 +41,8 @@ CXXEFLAGS := $(CXXFLAGS) -Wall -std=c++11
CC ?= gcc
CXX ?= g++
SYS = $(shell uname -s)
ifeq "clang" "$(CC)"
CC = gcc
CXX = g++
@ -75,25 +77,25 @@ ifeq "$(TEST_MMAP)" "1"
override CFLAGS_SAFE += -DUSEMMAP=1
endif
ifneq "$(shell uname -s)" "Haiku"
ifneq "$(shell uname -s)" "OpenBSD"
ifneq "$(SYS)" "Haiku"
ifneq "$(SYS)" "OpenBSD"
LDFLAGS += -lrt
endif
else
CFLAGS_SAFE += -DUSEMMAP=1
endif
ifeq "$(shell uname -s)" "OpenBSD"
ifeq "$(SYS)" "OpenBSD"
CC = egcc
CXX = eg++
PLUGIN_FLAGS += -I/usr/local/include
endif
ifeq "$(shell uname -s)" "DragonFly"
ifeq "$(SYS)" "DragonFly"
PLUGIN_FLAGS += -I/usr/local/include
endif
ifeq "$(shell uname -s)" "SunOS"
ifeq "$(SYS)" "SunOS"
PLUGIN_FLAGS += -I/usr/include/gmp
endif

View File

@ -30,7 +30,9 @@ BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/nul
VERSION = $(shell grep '^$(HASH)define VERSION ' ./config.h | cut -d '"' -f2)
ifeq "$(shell uname)" "OpenBSD"
SYS = $(shell uname -s)
ifeq "$(SYS)" "OpenBSD"
LLVM_CONFIG ?= $(BIN_PATH)/llvm-config
HAS_OPT = $(shell test -x $(BIN_PATH)/opt && echo 0 || echo 1)
ifeq "$(HAS_OPT)" "1"
@ -275,13 +277,13 @@ CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
# User teor2345 reports that this is required to make things work on MacOS X.
ifeq "$(shell uname)" "Darwin"
ifeq "$(SYS)" "Darwin"
CLANG_LFL += -Wl,-flat_namespace -Wl,-undefined,suppress
else
CLANG_CPPFL += -Wl,-znodelete
endif
ifeq "$(shell uname)" "OpenBSD"
ifeq "$(SYS)" "OpenBSD"
CLANG_LFL += `$(LLVM_CONFIG) --libdir`/libLLVM.so
CLANG_CPPFL += -mno-retpoline
CFLAGS += -mno-retpoline

View File

@ -11,6 +11,8 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++3.13a (development)
- frida_mode - new mode that uses frida to fuzz binary-only targets,
thanks to @WorksButNotTested!
- create a fuzzing dictionary with the help of CodeQL thanks to
@microsvuln! see utils/autodict_ql
- afl-fuzz:
- added patch by @realmadsci to support @@ as part of command line
options, e.g. `afl-fuzz ... -- ./target --infile=@@`
@ -20,6 +22,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- default cmplog level (-l) is now 2, better efficiency.
- ensure one fuzzer sync per cycle
- afl-cc:
- Leak Sanitizer support (AFL_USE_LSAN) added by Joshua Rogers, thanks!
- Removed InsTrim instrumentation as it is not as good as PCGUARD
### Version ++3.12c (release)

View File

@ -13,12 +13,14 @@
#include <stdio.h>
#define ASHMEM_DEVICE "/dev/ashmem"
int shmdt(const void* address) {
#if defined(SYS_shmdt)
int shmdt(const void *address) {
#if defined(SYS_shmdt)
return syscall(SYS_shmdt, address);
#else
#else
return syscall(SYS_ipc, SHMDT, 0, 0, 0, address, 0);
#endif
#endif
}
int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) {
@ -26,7 +28,7 @@ int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) {
int ret = 0;
if (__cmd == IPC_RMID) {
int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
struct ashmem_pin pin = {0, length};
ret = ioctl(__shmid, ASHMEM_UNPIN, &pin);
close(__shmid);
@ -77,6 +79,6 @@ void *shmat(int __shmid, const void *__shmaddr, int __shmflg) {
}
#endif /* !_ANDROID_ASHMEM_H */
#endif /* !__ANDROID__ */
#endif /* !_ANDROID_ASHMEM_H */
#endif /* !__ANDROID__ */

View File

@ -176,7 +176,7 @@ bool AFLLTOPass::runOnModule(Module &M) {
}
if (debug) { fprintf(stderr, "map address is 0x%lx\n", map_addr); }
if (debug) { fprintf(stderr, "map address is 0x%llx\n", map_addr); }
/* Get/set the globals for the SHM region. */

View File

@ -833,14 +833,13 @@ static void set_up_environment(char **argv) {
"handle_sigfpe=0:"
"handle_sigill=0", 0);
setenv("LSAN_OPTIONS",
setenv("LSAN_OPTIONS",
"exitcode=" STRINGIFY(LSAN_ERROR) ":"
"fast_unwind_on_malloc=0:"
"symbolize=0:"
"print_suppressions=0",
0);
if (get_afl_env("AFL_PRELOAD")) {
if (qemu_mode) {

View File

@ -820,10 +820,11 @@ static void edit_params(u32 argc, char **argv, char **envp) {
}
if (getenv("AFL_USE_LSAN")) {
cc_params[cc_par_cnt++] = "-fsanitize=leak";
cc_params[cc_par_cnt++] = "-includesanitizer/lsan_interface.h";
cc_params[cc_par_cnt++] =
"-D__AFL_LEAK_CHECK()=__lsan_do_leak_check()";
cc_params[cc_par_cnt++] = "-D__AFL_LEAK_CHECK()=__lsan_do_leak_check()";
}
if (getenv("AFL_USE_CFISAN")) {

View File

@ -560,7 +560,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
/* LSAN, too, does not support abort_on_error=1. */
if (!getenv("LSAN_OPTIONS"))
setenv("LSAN_OPTIONS",
setenv("LSAN_OPTIONS",
"exitcode=" STRINGIFY(LSAN_ERROR) ":"
"fast_unwind_on_malloc=0:"
"symbolize=0:"
@ -1314,8 +1314,9 @@ fsrv_run_result_t afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
/* A normal crash/abort */
(WIFSIGNALED(fsrv->child_status)) ||
/* special handling for msan and lsan */
(fsrv->uses_asan && (WEXITSTATUS(fsrv->child_status) == MSAN_ERROR ||
WEXITSTATUS(fsrv->child_status) == LSAN_ERROR)) ||
(fsrv->uses_asan &&
(WEXITSTATUS(fsrv->child_status) == MSAN_ERROR ||
WEXITSTATUS(fsrv->child_status) == LSAN_ERROR)) ||
/* the custom crash_exitcode was returned by the target */
(fsrv->uses_crash_exitcode &&
WEXITSTATUS(fsrv->child_status) == fsrv->crash_exitcode))) {

View File

@ -2502,7 +2502,6 @@ void check_asan_opts(afl_state_t *afl) {
}
}
/* Handle stop signal (Ctrl-C, etc). */

View File

@ -763,7 +763,7 @@ static void set_up_environment(afl_forkserver_t *fsrv, char **argv) {
"handle_sigfpe=0:"
"handle_sigill=0", 0);
setenv("LSAN_OPTIONS",
setenv("LSAN_OPTIONS",
"exitcode=" STRINGIFY(LSAN_ERROR) ":"
"fast_unwind_on_malloc=0:"
"symbolize=0:"