fastexit + code format

This commit is contained in:
vanhauser-thc
2022-10-11 08:53:49 +02:00
parent c5008362c6
commit e6e82948bf
11 changed files with 56 additions and 9 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

@ -8,11 +8,14 @@
- fix gramatron and grammar_mutator build scripts - fix gramatron and grammar_mutator build scripts
- enhancements to the afl-persistent-config and afl-system-config - enhancements to the afl-persistent-config and afl-system-config
scripts scripts
- afl-fuzz:
- force writing all stats on exit
- afl-cc: - afl-cc:
- make gcc_mode (afl-gcc-fast) work with gcc down to version 3.6 - make gcc_mode (afl-gcc-fast) work with gcc down to version 3.6
- qemu_mode: - qemu_mode:
- fixed 10x speed degredation in v4.03c, thanks to @ele7enxxh for - fixed 10x speed degredation in v4.03c, thanks to @ele7enxxh for
reporting! reporting!
- added qemu_mode/fastexit helper library
- unicorn_mode: - unicorn_mode:
- Enabled tricore arch (by @jma-qb) - Enabled tricore arch (by @jma-qb)
- Updated Capstone version in Rust bindings - Updated Capstone version in Rust bindings

View File

@ -245,7 +245,7 @@ struct afl_cmplog_pass : afl_base_pass {
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);
@ -281,7 +281,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,

View File

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

View File

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

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 tarets like Android or Wine.

View File

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

View File

@ -2570,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

@ -292,10 +292,10 @@ int LLVMFuzzerRunDriver(int *argcp, char ***argvp,
} }
bool in_afl = !(!getenv(SHM_FUZZ_ENV_VAR) || !getenv(SHM_ENV_VAR) || bool in_afl = !(!getenv(SHM_FUZZ_ENV_VAR) || !getenv(SHM_ENV_VAR) ||
fcntl(FORKSRV_FD, F_GETFD) == -1 || fcntl(FORKSRV_FD, F_GETFD) == -1 ||
fcntl(FORKSRV_FD + 1, F_GETFD) == -1); fcntl(FORKSRV_FD + 1, F_GETFD) == -1);
if (!in_afl) { __afl_sharedmem_fuzzing = 0; } if (!in_afl) { __afl_sharedmem_fuzzing = 0; }
output_file = stderr; output_file = stderr;
maybe_duplicate_stderr(); maybe_duplicate_stderr();

View File

@ -512,7 +512,7 @@ __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) { int reallocarr(void *ptr, size_t elem_len, size_t elem_cnt) {
void *ret = NULL; void *ret = NULL;
const size_t elem_tot = elem_len * elem_cnt; const size_t elem_tot = elem_len * elem_cnt;
if (elem_tot == 0) { if (elem_tot == 0) {