Compare commits

...

23 Commits
4.03c ... 4.04c

Author SHA1 Message Date
cbfa5207ba Merge pull request #1551 from AFLplusplus/dev
push to stable
2022-10-11 15:40:55 +02:00
bac6ba8907 v4.04c 2022-10-11 15:39:27 +02:00
de9d1ff4a0 doc fixes 2022-10-11 12:43:06 +02:00
e6e82948bf fastexit + code format 2022-10-11 08:53:49 +02:00
c5008362c6 Merge pull request #1543 from quinox/feat-make-on-gentoo
Support building LTO on Gentoo
2022-10-10 17:08:01 +02:00
db4fa9319d Fix #1548 2022-10-10 14:37:16 +02:00
680e6e91a1 Support building LTO on Gentoo 2022-10-08 09:51:26 +02:00
2107ece114 auto shmem fuzzing (#1541)
* auto shmem fuzzing

* print warning when forcing shmem fuzzing

* typos

* Shmem always

* typo fix

* fixes

Co-authored-by: Dominik Maier <dmnk@google.com>
2022-10-07 15:40:04 +02:00
5e04c9693b fix qemu_mode speed bug 2022-10-04 08:39:07 +02:00
9e4137a3eb Enabled tricore arch for unicornafl 2022-10-03 22:58:21 +02:00
jma
97fb0b5099 fix Rust speedtest example dependency (#1542) 2022-10-03 12:06:43 +02:00
9c6aebba05 typos 2022-10-03 11:04:23 +02:00
3e0fe86465 Merge pull request #1539 from devnexen/reallocarr
libdislocator adding netbsd's reallocarr
2022-10-01 18:27:02 +02:00
0eeddda2c8 libdislocator adding netbsd's reallocarr 2022-10-01 16:12:32 +01:00
586aec7116 Fixed typo in README.llvm.md (#1538)
Co-authored-by: van Hauser <vh@thc.org>
2022-09-29 12:42:04 +02:00
7e0171006a Merge pull request #1537 from AFLplusplus/dev
push to stable
2022-09-28 22:56:28 +02:00
96b7742611 enhancements to afl-persistent-config and afl-system-config 2022-09-28 21:36:25 +02:00
3c21e9f0d1 another attempt at stand-alone map fix 2022-09-27 15:51:16 +02:00
0f72a7473f Fix docs for fuzz_count in python 2022-09-27 13:45:39 +00:00
1ce0dcac3f fix standalone running with shared libs 2022-09-26 11:55:03 +02:00
77f253c1b9 fix custom mutator build scripts 2022-09-26 03:43:45 +02:00
ed54532f29 make gcc_plugin compilable for gcc 3.6.0 2022-09-23 23:19:10 +02:00
6ed40d5a08 4.04a init 2022-09-20 18:12:37 +02:00
35 changed files with 243 additions and 94 deletions

View File

@ -592,6 +592,7 @@ clean:
-$(MAKE) -C utils/argv_fuzzing clean -$(MAKE) -C utils/argv_fuzzing clean
-$(MAKE) -C utils/plot_ui clean -$(MAKE) -C utils/plot_ui clean
-$(MAKE) -C qemu_mode/unsigaction clean -$(MAKE) -C qemu_mode/unsigaction clean
-$(MAKE) -C qemu_mode/fastexit clean
-$(MAKE) -C qemu_mode/libcompcov clean -$(MAKE) -C qemu_mode/libcompcov clean
-$(MAKE) -C qemu_mode/libqasan clean -$(MAKE) -C qemu_mode/libqasan clean
-$(MAKE) -C frida_mode clean -$(MAKE) -C frida_mode clean

View File

@ -214,6 +214,17 @@ ifeq "$(LLVM_LTO)" "1"
ifeq "$(AFL_REAL_LD)" "" ifeq "$(AFL_REAL_LD)" ""
ifneq "$(shell readlink $(LLVM_BINDIR)/ld.lld 2>&1)" "" ifneq "$(shell readlink $(LLVM_BINDIR)/ld.lld 2>&1)" ""
AFL_REAL_LD = $(LLVM_BINDIR)/ld.lld AFL_REAL_LD = $(LLVM_BINDIR)/ld.lld
else ifneq "$(shell command -v ld.lld 2>/dev/null)" ""
AFL_REAL_LD = $(shell command -v ld.lld)
TMP_LDLDD_VERSION = $(shell $(AFL_REAL_LD) --version | awk '{ print $$2 }')
ifeq "$(LLVMVER)" "$(TMP_LDLDD_VERSION)"
$(warning ld.lld found in a weird location ($(AFL_REAL_LD)), but its the same version as LLVM so we will allow it)
else
$(warning ld.lld found in a weird location ($(AFL_REAL_LD)) and its of a different version than LLMV ($(TMP_LDLDD_VERSION) vs. $(LLVMVER)) - cannot enable LTO mode)
AFL_REAL_LD=
LLVM_LTO = 0
endif
undefine TMP_LDLDD_VERSION
else else
$(warning ld.lld not found, cannot enable LTO mode) $(warning ld.lld not found, cannot enable LTO mode)
LLVM_LTO = 0 LLVM_LTO = 0
@ -229,7 +240,7 @@ AFL_CLANG_FUSELD=
ifeq "$(LLVM_LTO)" "1" ifeq "$(LLVM_LTO)" "1"
ifeq "$(shell echo 'int main() {return 0; }' | $(CLANG_BIN) -x c - -fuse-ld=`command -v ld` -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1" ifeq "$(shell echo 'int main() {return 0; }' | $(CLANG_BIN) -x c - -fuse-ld=`command -v ld` -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
AFL_CLANG_FUSELD=1 AFL_CLANG_FUSELD=1
ifeq "$(shell echo 'int main() {return 0; }' | $(CLANG_BIN) -x c - -fuse-ld=ld.lld --ld-path=$(LLVM_BINDIR)/ld.lld -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1" ifeq "$(shell echo 'int main() {return 0; }' | $(CLANG_BIN) -x c - -fuse-ld=ld.lld --ld-path=$(AFL_REAL_LD) -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
AFL_CLANG_LDPATH=1 AFL_CLANG_LDPATH=1
endif endif
else else

View File

@ -2,7 +2,7 @@
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/master/static/aflpp_bg.svg" alt="AFL++ logo" width="250" heigh="250"> <img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/master/static/aflpp_bg.svg" alt="AFL++ logo" width="250" heigh="250">
Release version: [4.03c](https://github.com/AFLplusplus/AFLplusplus/releases) Release version: [4.04c](https://github.com/AFLplusplus/AFLplusplus/releases)
GitHub version: 4.04a GitHub version: 4.04a

View File

@ -113,10 +113,10 @@ EOF
grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub 2>/dev/null || echo Error: /etc/default/grub with GRUB_CMDLINE_LINUX_DEFAULT is not present, cannot set boot options grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub 2>/dev/null || echo Error: /etc/default/grub with GRUB_CMDLINE_LINUX_DEFAULT is not present, cannot set boot options
grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub 2>/dev/null && { grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub 2>/dev/null && {
grep -E '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub | grep -E -q hardened_usercopy=off || { grep -E '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub | grep -E -q 'noibrs pcid nopti' || {
echo "Configuring performance boot options" echo "Configuring performance boot options"
LINE=`grep -E '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub | sed 's/^GRUB_CMDLINE_LINUX_DEFAULT=//' | tr -d '"'` LINE=`grep -E '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub | sed 's/^GRUB_CMDLINE_LINUX_DEFAULT=//' | tr -d '"'`
OPTIONS="$LINE ibpb=off ibrs=off kpti=off l1tf=off mds=off mitigations=off no_stf_barrier noibpb noibrs nopcid nopti nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=off pti=off spec_store_bypass_disable=off spectre_v2=off stf_barrier=off srbds=off noexec=off noexec32=off tsx=on tsx=on tsx_async_abort=off mitigations=off audit=0 hardened_usercopy=off ssbd=force-off" OPTIONS="$LINE ibpb=off ibrs=off kpti=off l1tf=off mds=off mitigations=off no_stf_barrier noibpb noibrs pcid nopti nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=on pti=off spec_store_bypass_disable=off spectre_v2=off stf_barrier=off srbds=off noexec=off noexec32=off tsx=on tsx=on tsx_async_abort=off mitigations=off audit=0 hardened_usercopy=off ssbd=force-off"
echo Setting boot options in /etc/default/grub to GRUB_CMDLINE_LINUX_DEFAULT=\"$OPTIONS\" echo Setting boot options in /etc/default/grub to GRUB_CMDLINE_LINUX_DEFAULT=\"$OPTIONS\"
sed -i "s|^GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT=\"$OPTIONS\"|" /etc/default/grub sed -i "s|^GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT=\"$OPTIONS\"|" /etc/default/grub
} }

View File

@ -47,9 +47,9 @@ if [ "$PLATFORM" = "Linux" ] ; then
} > /dev/null } > /dev/null
echo Settings applied. echo Settings applied.
echo echo
dmesg | grep -E -q 'nospectre_v2|spectre_v2=off' || { dmesg | grep -E -q 'noibrs pcid nopti' || {
echo It is recommended to boot the kernel with lots of security off - if you are running a machine that is in a secured network - so set this: echo It is recommended to boot the kernel with lots of security off - if you are running a machine that is in a secured network - so set this:
echo ' /etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="ibpb=off ibrs=off kpti=0 l1tf=off mds=off mitigations=off no_stf_barrier noibpb noibrs nopcid nopti nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=off pti=off spec_store_bypass_disable=off spectre_v2=off stf_barrier=off srbds=off noexec=off noexec32=off tsx=on tsx_async_abort=off arm64.nopauth audit=0 hardened_usercopy=off ssbd=force-off"' echo ' /etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="ibpb=off ibrs=off kpti=0 l1tf=off mds=off mitigations=off no_stf_barrier noibpb noibrs pcid nopti nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=on pti=off spec_store_bypass_disable=off spectre_v2=off stf_barrier=off srbds=off noexec=off noexec32=off tsx=on tsx_async_abort=off arm64.nopauth audit=0 hardened_usercopy=off ssbd=force-off"'
echo echo
} }
echo If you run fuzzing instances in docker, run them with \"--security-opt seccomp=unconfined\" for more speed. echo If you run fuzzing instances in docker, run them with \"--security-opt seccomp=unconfined\" for more speed.

View File

@ -125,7 +125,7 @@ else
} }
fi fi
test -d json-c/.git || { echo "[-] not checked out, please install git or check your internet connection." ; exit 1 ; } test -e json-c/.git || { echo "[-] not checked out, please install git or check your internet connection." ; exit 1 ; }
echo "[+] Got json-c." echo "[+] Got json-c."
test -e json-c/.libs/libjson-c.a || { test -e json-c/.libs/libjson-c.a || {

View File

@ -119,7 +119,7 @@ else
} }
fi fi
test -f grammar_mutator/.git || { echo "[-] not checked out, please install git or check your internet connection." ; exit 1 ; } test -e grammar_mutator/.git || { echo "[-] not checked out, please install git or check your internet connection." ; exit 1 ; }
echo "[+] Got grammar mutator." echo "[+] Got grammar mutator."
cd "grammar_mutator" || exit 1 cd "grammar_mutator" || exit 1

View File

@ -4,6 +4,26 @@
release of the tool. See README.md for the general instruction manual. release of the tool. See README.md for the general instruction manual.
### Version ++4.04c (release)
- fix gramatron and grammar_mutator build scripts
- enhancements to the afl-persistent-config and afl-system-config
scripts
- afl-fuzz:
- force writing all stats on exit
- afl-cc:
- make gcc_mode (afl-gcc-fast) work with gcc down to version 3.6
- qemu_mode:
- fixed 10x speed degredation in v4.03c, thanks to @ele7enxxh for
reporting!
- added qemu_mode/fastexit helper library
- unicorn_mode:
- Enabled tricore arch (by @jma-qb)
- Updated Capstone version in Rust bindings
- llvm-mode:
- AFL runtime will always pass inputs via shared memory, when possible,
ignoring the command line.
### Version ++4.03c (release) ### Version ++4.03c (release)
- Building now gives a build summary what succeeded and what not - Building now gives a build summary what succeeded and what not
- afl-fuzz: - afl-fuzz:

View File

@ -68,7 +68,7 @@ Python:
def init(seed): def init(seed):
pass pass
def fuzz_count(buf, add_buf, max_size): def fuzz_count(buf):
return cnt return cnt
def fuzz(buf, add_buf, max_size): def fuzz(buf, add_buf, max_size):

View File

@ -26,7 +26,7 @@
/* Version string: */ /* Version string: */
// c = release, a = volatile github dev, e = experimental branch // c = release, a = volatile github dev, e = experimental branch
#define VERSION "++4.03c" #define VERSION "++4.04c"
/****************************************************** /******************************************************
* * * *

View File

@ -116,7 +116,7 @@ PCGUARD analysis.
Several options are present to make llvm_mode faster or help it rearrange the Several options are present to make llvm_mode faster or help it rearrange the
code to make afl-fuzz path discovery easier. code to make afl-fuzz path discovery easier.
If you need just to instrument specific parts of the code, you can the If you need just to instrument specific parts of the code, you can create the
instrument file list which C/C++ files to actually instrument. See instrument file list which C/C++ files to actually instrument. See
[README.instrument_list.md](README.instrument_list.md) [README.instrument_list.md](README.instrument_list.md)

View File

@ -97,11 +97,13 @@ u8 *__afl_dictionary;
u8 *__afl_fuzz_ptr; u8 *__afl_fuzz_ptr;
static u32 __afl_fuzz_len_dummy; static u32 __afl_fuzz_len_dummy;
u32 *__afl_fuzz_len = &__afl_fuzz_len_dummy; u32 *__afl_fuzz_len = &__afl_fuzz_len_dummy;
int __afl_sharedmem_fuzzing __attribute__((weak));
u32 __afl_final_loc; u32 __afl_final_loc;
u32 __afl_map_size = MAP_SIZE; u32 __afl_map_size = MAP_SIZE;
u32 __afl_dictionary_len; u32 __afl_dictionary_len;
u64 __afl_map_addr; u64 __afl_map_addr;
u32 __afl_first_final_loc;
// for the __AFL_COVERAGE_ON/__AFL_COVERAGE_OFF features to work: // for the __AFL_COVERAGE_ON/__AFL_COVERAGE_OFF features to work:
int __afl_selective_coverage __attribute__((weak)); int __afl_selective_coverage __attribute__((weak));
@ -118,8 +120,6 @@ __thread PREV_LOC_T __afl_prev_caller[CTX_MAX_K];
__thread u32 __afl_prev_ctx; __thread u32 __afl_prev_ctx;
#endif #endif
int __afl_sharedmem_fuzzing __attribute__((weak));
struct cmp_map *__afl_cmp_map; struct cmp_map *__afl_cmp_map;
struct cmp_map *__afl_cmp_map_backup; struct cmp_map *__afl_cmp_map_backup;
@ -319,7 +319,8 @@ static void __afl_map_shm(void) {
} else { } else {
if (!getenv("AFL_QUIET")) if (__afl_final_loc > MAP_INITIAL_SIZE && !getenv("AFL_QUIET")) {
fprintf(stderr, fprintf(stderr,
"Warning: AFL++ tools might need to set AFL_MAP_SIZE to %u " "Warning: AFL++ tools might need to set AFL_MAP_SIZE to %u "
"to be able to run this instrumented program if this " "to be able to run this instrumented program if this "
@ -332,6 +333,8 @@ static void __afl_map_shm(void) {
} }
}
} else { } else {
if (getenv("AFL_DUMP_MAP_SIZE")) { if (getenv("AFL_DUMP_MAP_SIZE")) {
@ -343,25 +346,39 @@ static void __afl_map_shm(void) {
} }
if (!id_str && __afl_area_ptr_dummy == __afl_area_initial) { if (__afl_sharedmem_fuzzing && (!id_str || !getenv(SHM_FUZZ_ENV_VAR) ||
fcntl(FORKSRV_FD, F_GETFD) == -1 ||
fcntl(FORKSRV_FD + 1, F_GETFD) == -1)) {
if (__afl_debug) {
fprintf(stderr,
"DEBUG: running not inside afl-fuzz, disabling shared memory "
"testcases\n");
}
__afl_sharedmem_fuzzing = 0;
}
if (!id_str) {
u32 val = 0; u32 val = 0;
u8 *ptr; u8 *ptr;
if ((ptr = getenv("AFL_MAP_SIZE")) != NULL) val = atoi(ptr); if ((ptr = getenv("AFL_MAP_SIZE")) != NULL) { val = atoi(ptr); }
if (val > MAP_INITIAL_SIZE) { if (val > MAP_INITIAL_SIZE) {
__afl_map_size = val; __afl_map_size = val;
__afl_area_ptr_dummy = malloc(__afl_map_size);
if (!__afl_area_ptr_dummy) {
fprintf(stderr, } else {
"Error: AFL++ could not aquire %u bytes of memory, exiting!\n",
__afl_map_size);
exit(-1);
} if (__afl_first_final_loc > MAP_INITIAL_SIZE) {
// done in second stage constructor
__afl_map_size = __afl_first_final_loc;
} else { } else {
@ -369,6 +386,14 @@ static void __afl_map_shm(void) {
} }
}
if (__afl_map_size > MAP_INITIAL_SIZE && __afl_final_loc < __afl_map_size) {
__afl_final_loc = __afl_map_size;
}
if (__afl_debug) { if (__afl_debug) {
fprintf(stderr, "DEBUG: (0) init map size is %u to %p\n", __afl_map_size, fprintf(stderr, "DEBUG: (0) init map size is %u to %p\n", __afl_map_size,
@ -516,7 +541,9 @@ static void __afl_map_shm(void) {
} }
} else if (__afl_final_loc > __afl_map_size) { } else if (__afl_final_loc > MAP_INITIAL_SIZE &&
__afl_final_loc > __afl_first_final_loc) {
if (__afl_area_initial != __afl_area_ptr_dummy) { if (__afl_area_initial != __afl_area_ptr_dummy) {
@ -531,13 +558,13 @@ static void __afl_map_shm(void) {
if (!__afl_area_ptr_dummy) { if (!__afl_area_ptr_dummy) {
fprintf(stderr, fprintf(stderr,
"Error: AFL++ could not aquire %u bytes of memory, exiting!\n", "Error: AFL++ could not acquire %u bytes of memory, exiting!\n",
__afl_final_loc); __afl_final_loc);
exit(-1); exit(-1);
} }
} } // else: nothing to be done
__afl_area_ptr_backup = __afl_area_ptr; __afl_area_ptr_backup = __afl_area_ptr;
@ -745,10 +772,10 @@ static void __afl_start_snapshots(void) {
assume we're not running in forkserver mode and just execute program. */ assume we're not running in forkserver mode and just execute program. */
status |= (FS_OPT_ENABLED | FS_OPT_SNAPSHOT | FS_OPT_NEWCMPLOG); status |= (FS_OPT_ENABLED | FS_OPT_SNAPSHOT | FS_OPT_NEWCMPLOG);
if (__afl_sharedmem_fuzzing != 0) status |= FS_OPT_SHDMEM_FUZZ; if (__afl_sharedmem_fuzzing) { status |= FS_OPT_SHDMEM_FUZZ; }
if (__afl_map_size <= FS_OPT_MAX_MAPSIZE) if (__afl_map_size <= FS_OPT_MAX_MAPSIZE)
status |= (FS_OPT_SET_MAPSIZE(__afl_map_size) | FS_OPT_MAPSIZE); status |= (FS_OPT_SET_MAPSIZE(__afl_map_size) | FS_OPT_MAPSIZE);
if (__afl_dictionary_len && __afl_dictionary) status |= FS_OPT_AUTODICT; if (__afl_dictionary_len && __afl_dictionary) { status |= FS_OPT_AUTODICT; }
memcpy(tmp, &status, 4); memcpy(tmp, &status, 4);
if (write(FORKSRV_FD + 1, tmp, 4) != 4) { return; } if (write(FORKSRV_FD + 1, tmp, 4) != 4) { return; }
@ -1009,7 +1036,7 @@ static void __afl_start_forkserver(void) {
} }
if (__afl_sharedmem_fuzzing != 0) { status_for_fsrv |= FS_OPT_SHDMEM_FUZZ; } if (__afl_sharedmem_fuzzing) { status_for_fsrv |= FS_OPT_SHDMEM_FUZZ; }
if (status_for_fsrv) { if (status_for_fsrv) {
status_for_fsrv |= (FS_OPT_ENABLED | FS_OPT_NEWCMPLOG); status_for_fsrv |= (FS_OPT_ENABLED | FS_OPT_NEWCMPLOG);
@ -1375,21 +1402,24 @@ __attribute__((constructor(1))) void __afl_auto_second(void) {
if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return; if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return;
u8 *ptr; u8 *ptr;
if (__afl_final_loc) { if (__afl_final_loc > MAP_INITIAL_SIZE) {
__afl_first_final_loc = __afl_final_loc + 1;
if (__afl_area_ptr && __afl_area_ptr != __afl_area_initial) if (__afl_area_ptr && __afl_area_ptr != __afl_area_initial)
free(__afl_area_ptr); free(__afl_area_ptr);
if (__afl_map_addr) if (__afl_map_addr)
ptr = (u8 *)mmap((void *)__afl_map_addr, __afl_final_loc, ptr = (u8 *)mmap((void *)__afl_map_addr, __afl_first_final_loc,
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_FIXED_NOREPLACE | MAP_SHARED | MAP_ANONYMOUS, -1, 0); MAP_FIXED_NOREPLACE | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
else else
ptr = (u8 *)malloc(__afl_final_loc); ptr = (u8 *)malloc(__afl_first_final_loc);
if (ptr && (ssize_t)ptr != -1) { if (ptr && (ssize_t)ptr != -1) {
__afl_area_ptr = ptr; __afl_area_ptr = ptr;
__afl_area_ptr_dummy = __afl_area_ptr;
__afl_area_ptr_backup = __afl_area_ptr; __afl_area_ptr_backup = __afl_area_ptr;
} }
@ -1407,6 +1437,8 @@ __attribute__((constructor(0))) void __afl_auto_first(void) {
__afl_already_initialized_first = 1; __afl_already_initialized_first = 1;
if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return; if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return;
/*
u8 *ptr = (u8 *)malloc(MAP_INITIAL_SIZE); u8 *ptr = (u8 *)malloc(MAP_INITIAL_SIZE);
if (ptr && (ssize_t)ptr != -1) { if (ptr && (ssize_t)ptr != -1) {
@ -1416,6 +1448,8 @@ __attribute__((constructor(0))) void __afl_auto_first(void) {
} }
*/
} // ptr memleak report is a false positive } // ptr memleak report is a false positive
/* The following stuff deals with supporting -fsanitize-coverage=trace-pc-guard. /* The following stuff deals with supporting -fsanitize-coverage=trace-pc-guard.

View File

@ -244,7 +244,7 @@ struct afl_cmplog_pass : afl_base_pass {
tree t = build_nonstandard_integer_type(sz, 1); tree t = build_nonstandard_integer_type(sz, 1);
tree s = make_ssa_name(t); tree s = make_ssa_name(t);
gimple *g = gimple_build_assign(s, VIEW_CONVERT_EXPR, gimple g = gimple_build_assign(s, VIEW_CONVERT_EXPR,
build1(VIEW_CONVERT_EXPR, t, lhs)); build1(VIEW_CONVERT_EXPR, t, lhs));
lhs = s; lhs = s;
gsi_insert_before(&gsi, g, GSI_SAME_STMT); gsi_insert_before(&gsi, g, GSI_SAME_STMT);
@ -264,7 +264,7 @@ struct afl_cmplog_pass : afl_base_pass {
if (!is_gimple_val(lhs)) { if (!is_gimple_val(lhs)) {
tree s = make_ssa_name(t); tree s = make_ssa_name(t);
gimple *g = gimple_build_assign(s, lhs); gimple g = gimple_build_assign(s, lhs);
lhs = s; lhs = s;
gsi_insert_before(&gsi, g, GSI_SAME_STMT); gsi_insert_before(&gsi, g, GSI_SAME_STMT);
@ -274,7 +274,7 @@ struct afl_cmplog_pass : afl_base_pass {
if (!is_gimple_val(rhs)) { if (!is_gimple_val(rhs)) {
tree s = make_ssa_name(t); tree s = make_ssa_name(t);
gimple *g = gimple_build_assign(s, rhs); gimple g = gimple_build_assign(s, rhs);
rhs = s; rhs = s;
gsi_insert_before(&gsi, g, GSI_SAME_STMT); gsi_insert_before(&gsi, g, GSI_SAME_STMT);
@ -282,7 +282,7 @@ struct afl_cmplog_pass : afl_base_pass {
/* Insert the call. */ /* Insert the call. */
tree att = build_int_cst(t8u, attr); tree att = build_int_cst(t8u, attr);
gimple *call; gimple call;
if (pass_n) if (pass_n)
call = gimple_build_call(fn, 4, lhs, rhs, att, call = gimple_build_call(fn, 4, lhs, rhs, att,
build_int_cst(t8u, sz / 8 - 1)); build_int_cst(t8u, sz / 8 - 1));
@ -305,7 +305,7 @@ struct afl_cmplog_pass : afl_base_pass {
gimple_stmt_iterator gsi = gsi_last_bb(bb); gimple_stmt_iterator gsi = gsi_last_bb(bb);
if (gsi_end_p(gsi)) continue; if (gsi_end_p(gsi)) continue;
gimple *stmt = gsi_stmt(gsi); gimple stmt = gsi_stmt(gsi);
if (gimple_code(stmt) == GIMPLE_COND) { if (gimple_code(stmt) == GIMPLE_COND) {

View File

@ -241,7 +241,7 @@ struct afl_cmptrs_pass : afl_base_pass {
for (gimple_stmt_iterator gsi = gsi_after_labels(bb); !gsi_end_p(gsi); for (gimple_stmt_iterator gsi = gsi_after_labels(bb); !gsi_end_p(gsi);
gsi_next(&gsi)) { gsi_next(&gsi)) {
gimple *stmt = gsi_stmt(gsi); gimple stmt = gsi_stmt(gsi);
/* We're only interested in GIMPLE_CALLs. */ /* We're only interested in GIMPLE_CALLs. */
if (gimple_code(stmt) != GIMPLE_CALL) continue; if (gimple_code(stmt) != GIMPLE_CALL) continue;
@ -292,7 +292,7 @@ struct afl_cmptrs_pass : afl_base_pass {
if (!is_gimple_val(c)) { if (!is_gimple_val(c)) {
tree s = make_ssa_name(tp8u); tree s = make_ssa_name(tp8u);
gimple *g = gimple_build_assign(s, c); gimple g = gimple_build_assign(s, c);
c = s; c = s;
gsi_insert_before(&gsi, g, GSI_SAME_STMT); gsi_insert_before(&gsi, g, GSI_SAME_STMT);
@ -302,7 +302,7 @@ struct afl_cmptrs_pass : afl_base_pass {
} }
gimple *call = gimple_build_call(fn, 2, arg[0], arg[1]); gimple call = gimple_build_call(fn, 2, arg[0], arg[1]);
gsi_insert_before(&gsi, call, GSI_SAME_STMT); gsi_insert_before(&gsi, call, GSI_SAME_STMT);
} }

View File

@ -498,3 +498,11 @@ struct afl_base_pass : gimple_opt_pass {
} // namespace } // namespace
// compatibility for older gcc versions
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
60200 /* >= version 6.2.0 */
#define gimple gimple *
#else
#define gimple gimple
#endif

View File

@ -125,7 +125,10 @@
*/ */
#include "afl-gcc-common.h" #include "afl-gcc-common.h"
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
60200 /* >= version 6.2.0 */
#include "memmodel.h" #include "memmodel.h"
#endif
/* This plugin, being under the same license as GCC, satisfies the /* This plugin, being under the same license as GCC, satisfies the
"GPL-compatible Software" definition in the GCC RUNTIME LIBRARY "GPL-compatible Software" definition in the GCC RUNTIME LIBRARY

View File

@ -1 +1 @@
dc19175a0b ff9de4fbeb

View File

@ -13,8 +13,8 @@ afl-cc.
The usual performance cost is 2-5x, which is considerably better than seen so The usual performance cost is 2-5x, which is considerably better than seen so
far in experiments with tools such as DynamoRIO and PIN. far in experiments with tools such as DynamoRIO and PIN.
The idea and much of the initial implementation comes from Andrew Griffiths. The The idea and much of the initial implementation comes from Andrew Griffiths.
actual implementation on current QEMU (shipped as qemuafl) is from Andrea The actual implementation on current QEMU (shipped as qemuafl) is from Andrea
Fioraldi. Special thanks to abiondo that re-enabled TCG chaining. Fioraldi. Special thanks to abiondo that re-enabled TCG chaining.
## 2) How to use QEMU mode ## 2) How to use QEMU mode
@ -30,17 +30,13 @@ glib2-devel).
Once the binaries are compiled, you can leverage the QEMU tool by calling Once the binaries are compiled, you can leverage the QEMU tool by calling
afl-fuzz and all the related utilities with `-Q` in the command line. afl-fuzz and all the related utilities with `-Q` in the command line.
Note that QEMU requires a generous memory limit to run; somewhere around 200 MB
is a good starting point, but considerably more may be needed for more complex
programs. The default `-m` limit will be automatically bumped up to 200 MB when
specifying `-Q` to afl-fuzz; be careful when overriding this.
In principle, if you set `CPU_TARGET` before calling ./build_qemu_support.sh, In principle, if you set `CPU_TARGET` before calling ./build_qemu_support.sh,
you should get a build capable of running non-native binaries (say, you can try you should get a build capable of running non-native binaries (say, you can try
`CPU_TARGET=arm`). This is also necessary for running 32-bit binaries on a `CPU_TARGET=arm`). This is also necessary for running 32-bit binaries on a
64-bit system (`CPU_TARGET=i386`). If you're trying to run QEMU on a different 64-bit system (`CPU_TARGET=i386`). If you're trying to run QEMU on a different
architecture, you can also set `HOST` to the cross-compiler prefix to use (for architecture, you can also set `HOST` to the cross-compiler prefix to use (for
example `HOST=arm-linux-gnueabi` to use arm-linux-gnueabi-gcc). example `HOST=arm-linux-gnueabi` to use arm-linux-gnueabi-gcc).
Another common target is `CPU_TARGET=aarch64`.
You can also compile statically-linked binaries by setting `STATIC=1`. This can You can also compile statically-linked binaries by setting `STATIC=1`. This can
be useful when compiling QEMU on a different system than the one you're planning be useful when compiling QEMU on a different system than the one you're planning
@ -219,9 +215,6 @@ program may be utilizing. In particular, it does not appear to have full support
for AVX2/FMA3. Using binaries for older CPUs or recompiling them with for AVX2/FMA3. Using binaries for older CPUs or recompiling them with
`-march=core2`, can help. `-march=core2`, can help.
Beyond that, this is an early-stage mechanism, so fields reports are welcome.
You can send them to <afl-users@googlegroups.com>.
## 14) Alternatives: static rewriting ## 14) Alternatives: static rewriting
Statically rewriting binaries just once, instead of attempting to translate them Statically rewriting binaries just once, instead of attempting to translate them

View File

@ -27,11 +27,12 @@ function and will patch the return address (on stack or in the link register) to
return to START (like WinAFL). return to START (like WinAFL).
*Note:* If the target is compiled with position independent code (PIE/PIC) qemu *Note:* If the target is compiled with position independent code (PIE/PIC) qemu
loads these to a specific base address. For 64 bit you have to add 0x4000000000 loads these to a specific base address. For amd64 bit you have to add
(9 zeroes) and for 32 bit 0x40000000 (7 zeroes) to the address. On strange 0x4000000000 (9 zeroes) and for 32 bit 0x40000000 (7 zeroes) to the address.
setups the base address set by QEMU for PIE executable may change. You can check For aarch64 it is usually 0x5500000000.
it printing the process map using `AFL_QEMU_DEBUG_MAPS=1 afl-qemu-trace On strange setups the base address set by QEMU for PIE executable may change.
TARGET-BINARY`. You can check it printing the process map using
`AFL_QEMU_DEBUG_MAPS=1 afl-qemu-trace TARGET-BINARY`.
If this address is not valid, afl-fuzz will error during startup with the If this address is not valid, afl-fuzz will error during startup with the
message that the forkserver was not found. message that the forkserver was not found.

View File

@ -360,8 +360,10 @@ if ! command -v "$CROSS" > /dev/null ; then
make -C libcompcov && echo "[+] libcompcov ready" make -C libcompcov && echo "[+] libcompcov ready"
echo "[+] Building unsigaction ..." echo "[+] Building unsigaction ..."
make -C unsigaction && echo "[+] unsigaction ready" make -C unsigaction && echo "[+] unsigaction ready"
echo "[+] Building fastexit ..."
make -C fastexit && echo "[+] fastexit ready"
echo "[+] Building libqasan ..." echo "[+] Building libqasan ..."
make -C libqasan && echo "[+] unsigaction ready" make -C libqasan && echo "[+] libqasan ready"
echo "[+] Building qemu libfuzzer helpers ..." echo "[+] Building qemu libfuzzer helpers ..."
make -C ../utils/aflpp_driver make -C ../utils/aflpp_driver
else else

View File

@ -0,0 +1,30 @@
#
# american fuzzy lop++ - fastexit
# --------------------------------
#
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
#
# Copyright 2019-2022 Andrea Fioraldi. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
TARGETS=fastexit.so fastexit32.so fastexit64.so
all: $(TARGETS)
fastexit.so: fastexit.c
@if $(CC) -fPIC -shared fastexit.c -o fastexit.so 2>/dev/null ; then echo "fastexit build success"; else echo "fastexit build failure (that's fine)"; fi
fastexit32.so: fastexit.c
@if $(CC) -fPIC -m32 -shared fastexit.c -o fastexit32.so 2>/dev/null ; then echo "fastexit32 build success"; else echo "fastexit32 build failure (that's fine)"; fi
fastexit64.so: fastexit.c
@if $(CC) -fPIC -m64 -shared fastexit.c -o fastexit64.so 2>/dev/null ; then echo "fastexit64 build success"; else echo "fastexit64 build failure (that's fine)"; fi
clean:
rm -f fastexit.so

View File

@ -0,0 +1,5 @@
# fastexit
This library forces _exit on exit when preloaded to gain speed.
Gives speed on complex targets like Android or Wine.

View File

@ -0,0 +1,6 @@
#include <unistd.h>
#include <stdlib.h>
void exit(int status) {
_exit(status);
}

View File

@ -306,9 +306,7 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) {
} }
size_t rem = len % align; size_t size = len + align;
size_t size = len;
if (rem) size += rem;
int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread

View File

@ -317,7 +317,7 @@ void parse_fsanitize(char *string) {
char *tmp = malloc(strlen(ptr)); char *tmp = malloc(strlen(ptr));
u32 count = 0, len, ende = 0; u32 count = 0, len, ende = 0;
if (!new || !tmp) { FATAL("could not aquire memory"); } if (!new || !tmp) { FATAL("could not acquire memory"); }
strcpy(new, "-fsanitize="); strcpy(new, "-fsanitize=");
do { do {

View File

@ -2132,6 +2132,20 @@ int main(int argc, char **argv_orig, char **envp) {
} }
if (afl->fsrv.out_file && afl->fsrv.use_shmem_fuzz) {
afl->fsrv.out_file = NULL;
afl->fsrv.use_stdin = 0;
if (!afl->unicorn_mode && !afl->fsrv.use_stdin) {
WARNF(
"You specified -f or @@ on the command line but the target harness "
"specified fuzz cases via shmem, switching to shmem!");
}
}
deunicode_extras(afl); deunicode_extras(afl);
dedup_extras(afl); dedup_extras(afl);
if (afl->extras_cnt) { OKF("Loaded a total of %u extras.", afl->extras_cnt); } if (afl->extras_cnt) { OKF("Loaded a total of %u extras.", afl->extras_cnt); }
@ -2556,6 +2570,7 @@ int main(int argc, char **argv_orig, char **envp) {
stop_fuzzing: stop_fuzzing:
afl->force_ui_update = 1; // ensure the screen is reprinted afl->force_ui_update = 1; // ensure the screen is reprinted
afl->stop_soon = 1; // ensure everything is written
show_stats(afl); // print the screen one last time show_stats(afl); // print the screen one last time
write_bitmap(afl); write_bitmap(afl);
save_auto(afl); save_auto(afl);

View File

@ -1268,7 +1268,7 @@ int main(int argc, char **argv_orig, char **envp) {
(new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) {
if (!be_quiet) if (!be_quiet)
ACTF("Aquired new map size for target: %u bytes\n", new_map_size); ACTF("Acquired new map size for target: %u bytes\n", new_map_size);
afl_shm_deinit(&shm); afl_shm_deinit(&shm);
afl_fsrv_kill(fsrv); afl_fsrv_kill(fsrv);

View File

@ -1252,7 +1252,7 @@ int main(int argc, char **argv_orig, char **envp) {
(new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) {
if (!be_quiet) if (!be_quiet)
ACTF("Aquired new map size for target: %u bytes\n", new_map_size); ACTF("Acquired new map size for target: %u bytes\n", new_map_size);
afl_shm_deinit(&shm); afl_shm_deinit(&shm);
afl_fsrv_kill(fsrv); afl_fsrv_kill(fsrv);

View File

@ -1 +1 @@
6e00ceac 0a31c2b28bf7037fe8b0ff376521fdbdf28a9efe

View File

@ -11,5 +11,5 @@ panic = "abort"
[dependencies] [dependencies]
unicornafl = { path = "../../../unicornafl/bindings/rust/", version="1.0.0" } unicornafl = { path = "../../../unicornafl/bindings/rust/", version="1.0.0" }
capstone="0.10.0" capstone="0.11.0"
libc="0.2.66" libc="0.2.66"

View File

@ -35,6 +35,7 @@ $AFL_HOME/afl-fuzz -i IN -o OUT ./a.out
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -68,7 +69,7 @@ __attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv);
int LLVMFuzzerRunDriver(int *argc, char ***argv, int LLVMFuzzerRunDriver(int *argc, char ***argv,
int (*callback)(const uint8_t *data, size_t size)); int (*callback)(const uint8_t *data, size_t size));
// Default nop ASan hooks for manual posisoning when not linking the ASan // Default nop ASan hooks for manual poisoning when not linking the ASan
// runtime // runtime
// https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning // https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
__attribute__((weak)) void __asan_poison_memory_region( __attribute__((weak)) void __asan_poison_memory_region(
@ -290,6 +291,12 @@ int LLVMFuzzerRunDriver(int *argcp, char ***argvp,
} }
bool in_afl = !(!getenv(SHM_FUZZ_ENV_VAR) || !getenv(SHM_ENV_VAR) ||
fcntl(FORKSRV_FD, F_GETFD) == -1 ||
fcntl(FORKSRV_FD + 1, F_GETFD) == -1);
if (!in_afl) { __afl_sharedmem_fuzzing = 0; }
output_file = stderr; output_file = stderr;
maybe_duplicate_stderr(); maybe_duplicate_stderr();
maybe_close_fd_mask(); maybe_close_fd_mask();
@ -310,23 +317,20 @@ int LLVMFuzzerRunDriver(int *argcp, char ***argvp,
int N = INT_MAX; int N = INT_MAX;
if (argc == 2 && !strcmp(argv[1], "-")) { if (!in_afl && argc == 2 && !strcmp(argv[1], "-")) {
__afl_sharedmem_fuzzing = 0;
__afl_manual_init(); __afl_manual_init();
return ExecuteFilesOnyByOne(argc, argv, callback); return ExecuteFilesOnyByOne(argc, argv, callback);
} else if (argc == 2 && argv[1][0] == '-') { } else if (argc == 2 && argv[1][0] == '-' && argv[1][1]) {
N = atoi(argv[1] + 1); N = atoi(argv[1] + 1);
} else if (argc == 2 && (N = atoi(argv[1])) > 0) { } else if (argc == 2 && argv[1][0] != '-' && (N = atoi(argv[1])) > 0) {
printf("WARNING: using the deprecated call style `%s %d`\n", argv[0], N); printf("WARNING: using the deprecated call style `%s %d`\n", argv[0], N);
} else if (argc > 1) { } else if (!in_afl && argc > 1 && argv[1][0] != '-') {
__afl_sharedmem_fuzzing = 0;
if (argc == 2) { __afl_manual_init(); } if (argc == 2) { __afl_manual_init(); }

View File

@ -34,7 +34,7 @@ heap-related security bugs in several ways:
- Size alignment to `max_align_t` can be enforced with `AFL_ALIGNED_ALLOC=1`. In - Size alignment to `max_align_t` can be enforced with `AFL_ALIGNED_ALLOC=1`. In
this case, a tail canary is inserted in the padding bytes at the end of the this case, a tail canary is inserted in the padding bytes at the end of the
allocated zone. This reduce the ability of libdislocator to detect allocated zone. This reduces the ability of libdislocator to detect
off-by-one bugs but also it makes libdislocator compliant to the C standard. off-by-one bugs but also it makes libdislocator compliant to the C standard.
Basically, it is inspired by some of the non-default options available for the Basically, it is inspired by some of the non-default options available for the

View File

@ -510,6 +510,24 @@ __attribute__((alloc_size(2, 3))) void *reallocarray(void *ptr, size_t elem_len,
} }
int reallocarr(void *ptr, size_t elem_len, size_t elem_cnt) {
void *ret = NULL;
const size_t elem_tot = elem_len * elem_cnt;
if (elem_tot == 0) {
void **h = &ptr;
*h = ret;
return 0;
}
ret = reallocarray(ptr, elem_len, elem_cnt);
return ret ? 0 : -1;
}
#if defined(__APPLE__) #if defined(__APPLE__)
size_t malloc_size(const void *ptr) { size_t malloc_size(const void *ptr) {