Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Written and maintained by Michal Zalewski <[email protected]>
#
# Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
# Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. 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.
Expand Down Expand Up @@ -111,8 +111,8 @@ all_done: test_build
.NOTPARALLEL: clean

clean:
rm -f $(PROGS) afl-as as afl-g++ afl-clang afl-clang++ *.o *~ a.out core core.[1-9][0-9]* *.stackdump test .test test-instr .test-instr0 .test-instr1 qemu_mode/qemu-2.3.0.tar.bz2 afl-qemu-trace
rm -rf out_dir qemu_mode/qemu-2.3.0
rm -f $(PROGS) my-afl-as afl-as as afl-g++ afl-clang afl-clang++ *.o *~ a.out core core.[1-9][0-9]* *.stackdump test .test test-instr .test-instr0 .test-instr1 qemu_mode/qemu-2.10.0.tar.bz2 afl-qemu-trace
rm -rf out_dir qemu_mode/qemu-2.10.0
$(MAKE) -C llvm_mode clean
$(MAKE) -C libdislocator clean
$(MAKE) -C libtokencap clean
Expand Down
22 changes: 18 additions & 4 deletions afl-analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Written and maintained by Michal Zalewski <[email protected]>

Copyright 2016 Google Inc. All rights reserved.
Copyright 2016, 2017 Google Inc. 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.
Expand Down Expand Up @@ -72,6 +72,7 @@ static s32 shm_id, /* ID of the SHM region */
dev_null_fd = -1; /* FD to /dev/null */

static u8 edges_only, /* Ignore hit counts? */
use_hex_offsets, /* Show hex offsets? */
use_stdin = 1; /* Use stdin for program input? */

static volatile u8
Expand Down Expand Up @@ -490,9 +491,13 @@ static void dump_hex(u8* buf, u32 len, u8* b_data) {
/* Every 16 digits, display offset. */

if (!((i + off) % 16)) {

if (off) SAYF(cRST cLCY ">");
SAYF(cRST cGRA "%s[%06u] " cRST, (i + off) ? "\n" : "", i + off);

if (use_hex_offsets)
SAYF(cRST cGRA "%s[%06x] " cRST, (i + off) ? "\n" : "", i + off);
else
SAYF(cRST cGRA "%s[%06u] " cRST, (i + off) ? "\n" : "", i + off);

}

Expand All @@ -516,7 +521,10 @@ static void dump_hex(u8* buf, u32 len, u8* b_data) {

#else

SAYF(" Offset %u, length %u: ", i, rlen);
if (use_hex_offsets)
SAYF(" Offset %x, length %u: ", i, rlen);
else
SAYF(" Offset %u, length %u: ", i, rlen);

switch (rtype) {

Expand Down Expand Up @@ -878,6 +886,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
u8 *tmp, *cp, *rsl, *own_copy;

/* Workaround for a QEMU stability glitch. */

setenv("QEMU_LOG", "nochain", 1);

memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);

/* Now we need to actually find qemu for argv[0]. */
Expand Down Expand Up @@ -1030,6 +1042,8 @@ int main(int argc, char** argv) {

if (optind == argc || !in_file) usage(argv[0]);

use_hex_offsets = !!getenv("AFL_ANALYZE_HEX");

setup_shm();
setup_signal_handlers();

Expand Down
58 changes: 46 additions & 12 deletions afl-fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Forkserver design by Jann Horn <[email protected]>

Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. 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.
Expand Down Expand Up @@ -124,7 +124,9 @@ EXP_ST u8 skip_deterministic, /* Skip deterministic stages? */
qemu_mode, /* Running in QEMU mode? */
skip_requested, /* Skip request, via SIGUSR1 */
run_over10m, /* Run time over 10 minutes? */
persistent_mode; /* Running in persistent mode? */
persistent_mode, /* Running in persistent mode? */
deferred_mode, /* Deferred forkserver mode? */
fast_cal; /* Try to calibrate faster? */

static s32 out_fd, /* Persistent fd for out_file */
dev_urandom_fd = -1, /* Persistent fd for /dev/urandom */
Expand Down Expand Up @@ -2437,11 +2439,14 @@ static u8 run_target(char** argv, u32 timeout) {

/* Report outcome to caller. */

if (child_timed_out) return FAULT_TMOUT;

if (WIFSIGNALED(status) && !stop_soon) {

kill_signal = WTERMSIG(status);

if (child_timed_out && kill_signal == SIGKILL) return FAULT_TMOUT;

return FAULT_CRASH;

}

/* A somewhat nasty hack for MSAN, which doesn't support abort_on_error and
Expand Down Expand Up @@ -2552,7 +2557,7 @@ static u8 calibrate_case(char** argv, struct queue_entry* q, u8* use_mem,
q->cal_failed++;

stage_name = "calibration";
stage_max = CAL_CYCLES;
stage_max = fast_cal ? 3 : CAL_CYCLES;

/* Make sure the forkserver is up before we do anything, and let's not
count its spin-up time toward binary calibration. */
Expand Down Expand Up @@ -3204,6 +3209,12 @@ static u8 save_if_interesting(char** argv, void* mem, u32 len, u8 fault) {
write_to_testcase(mem, len);
new_fault = run_target(argv, hang_tmout);

/* A corner case that one user reported bumping into: increasing the
timeout actually uncovers a crash. Make sure we don't discard it if
so. */

if (!stop_soon && new_fault == FAULT_CRASH) goto keep_as_crash;

if (stop_soon || new_fault != FAULT_TMOUT) return keeping;

}
Expand All @@ -3228,6 +3239,8 @@ static u8 save_if_interesting(char** argv, void* mem, u32 len, u8 fault) {

case FAULT_CRASH:

keep_as_crash:

/* This is handled in a manner roughly similar to timeouts,
except for slightly different limits and no need to re-run test
cases. */
Expand Down Expand Up @@ -3420,6 +3433,7 @@ static void write_stats_file(double bitmap_cvg, double stability, double eps) {
"exec_timeout : %u\n"
"afl_banner : %s\n"
"afl_version : " VERSION "\n"
"target_mode : %s%s%s%s%s%s%s\n"
"command_line : %s\n",
start_time / 1000, get_cur_time() / 1000, getpid(),
queue_cycle ? (queue_cycle - 1) : 0, total_execs, eps,
Expand All @@ -3428,7 +3442,13 @@ static void write_stats_file(double bitmap_cvg, double stability, double eps) {
queued_variable, stability, bitmap_cvg, unique_crashes,
unique_hangs, last_path_time / 1000, last_crash_time / 1000,
last_hang_time / 1000, total_execs - last_crash_execs,
exec_tmout, use_banner, orig_cmdline);
exec_tmout, use_banner,
qemu_mode ? "qemu " : "", dumb_mode ? " dumb " : "",
no_forkserver ? "no_forksrv " : "", crash_mode ? "crash " : "",
persistent_mode ? "persistent " : "", deferred_mode ? "deferred " : "",
(qemu_mode || dumb_mode || no_forkserver || crash_mode ||
persistent_mode || deferred_mode) ? "" : "default",
orig_cmdline);
/* ignore errors */

fclose(f);
Expand Down Expand Up @@ -3693,9 +3713,13 @@ static void maybe_delete_out_dir(void) {
/* Okay, let's get the ball rolling! First, we need to get rid of the entries
in <out_dir>/.synced/.../id:*, if any are present. */

fn = alloc_printf("%s/.synced", out_dir);
if (delete_files(fn, NULL)) goto dir_cleanup_failed;
ck_free(fn);
if (!in_place_resume) {

fn = alloc_printf("%s/.synced", out_dir);
if (delete_files(fn, NULL)) goto dir_cleanup_failed;
ck_free(fn);

}

/* Next, we need to clean up <out_dir>/queue/.state/ subdirectories: */

Expand Down Expand Up @@ -4424,7 +4448,8 @@ static void show_init_stats(void) {
}


/* Find first power of two greater or equal to val. */
/* Find first power of two greater or equal to val (assuming val under
2^31). */

static u32 next_p2(u32 val) {

Expand Down Expand Up @@ -6933,6 +6958,7 @@ EXP_ST void check_binary(u8* fname) {

OKF(cPIN "Deferred forkserver binary detected.");
setenv(DEFER_ENV_VAR, "1", 1);
deferred_mode = 1;

} else if (getenv("AFL_DEFER_FORKSRV")) {

Expand Down Expand Up @@ -7132,7 +7158,10 @@ EXP_ST void setup_dirs_fds(void) {
if (sync_id) {

tmp = alloc_printf("%s/.synced/", out_dir);
if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);

if (mkdir(tmp, 0700) && (!in_place_resume || errno != EEXIST))
PFATAL("Unable to create '%s'", tmp);

ck_free(tmp);

}
Expand Down Expand Up @@ -7580,6 +7609,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
u8 *tmp, *cp, *rsl, *own_copy;

/* Workaround for a QEMU stability glitch. */

setenv("QEMU_LOG", "nochain", 1);

memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);

new_argv[2] = target_path;
Expand Down Expand Up @@ -7887,8 +7920,9 @@ int main(int argc, char** argv) {

if (getenv("AFL_NO_FORKSRV")) no_forkserver = 1;
if (getenv("AFL_NO_CPU_RED")) no_cpu_meter_red = 1;
if (getenv("AFL_NO_ARITH")) no_arith = 1;
if (getenv("AFL_NO_ARITH")) no_arith = 1;
if (getenv("AFL_SHUFFLE_QUEUE")) shuffle_queue = 1;
if (getenv("AFL_FAST_CAL")) fast_cal = 1;

if (getenv("AFL_HANG_TMOUT")) {
hang_tmout = atoi(getenv("AFL_HANG_TMOUT"));
Expand Down
8 changes: 7 additions & 1 deletion afl-showmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Written and maintained by Michal Zalewski <[email protected]>

Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. 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.
Expand Down Expand Up @@ -297,6 +297,8 @@ static void run_target(char** argv) {

if (!getenv("LD_BIND_LAZY")) setenv("LD_BIND_NOW", "1", 0);

setsid();

execv(target_path, argv);

*(u32*)trace_bits = EXEC_FAIL_SIG;
Expand Down Expand Up @@ -561,6 +563,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
u8 *tmp, *cp, *rsl, *own_copy;

/* Workaround for a QEMU stability glitch. */

setenv("QEMU_LOG", "nochain", 1);

memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);

new_argv[2] = target_path;
Expand Down
11 changes: 10 additions & 1 deletion afl-tmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Written and maintained by Michal Zalewski <[email protected]>

Copyright 2015, 2016 Google Inc. All rights reserved.
Copyright 2015, 2016, 2017 Google Inc. 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.
Expand Down Expand Up @@ -287,6 +287,8 @@ static u8 run_target(char** argv, u8* mem, u32 len, u8 first_run) {
close(dev_null_fd);
close(prog_in_fd);

setsid();

if (mem_limit) {

r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;
Expand Down Expand Up @@ -343,8 +345,11 @@ static u8 run_target(char** argv, u8* mem, u32 len, u8 first_run) {
total_execs++;

if (stop_soon) {

SAYF(cRST cLRD "\n+++ Minimization aborted by user +++\n" cRST);
close(write_to_file(out_file, in_data, in_len));
exit(1);

}

/* Always discard inputs that time out. */
Expand Down Expand Up @@ -893,6 +898,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
u8 *tmp, *cp, *rsl, *own_copy;

/* Workaround for a QEMU stability glitch. */

setenv("QEMU_LOG", "nochain", 1);

memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);

/* Now we need to actually find qemu for argv[0]. */
Expand Down
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/* Version string: */

#define VERSION "2.49b"
#define VERSION "2.52b"

/******************************************************
* *
Expand Down
43 changes: 43 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,49 @@ Not sure if you should upgrade? The lowest currently recommended version
is 2.41b. If you're stuck on an earlier release, it's strongly advisable
to get on with the times.

---------------------------
Version 2.52b (2017-11-04):
---------------------------

- Upgraded QEMU patches from 2.3.0 to 2.10.0. Required troubleshooting
several weird issues. All the legwork done by Andrew Griffiths.

- Added setsid to afl-showmap. See the notes for 2.51b.

- Added target mode (deferred, persistent, qemu, etc) to fuzzer_stats.
Requested by Jakub Wilk.

- afl-tmin should now save a partially minimized file when Ctrl-C
is pressed. Suggested by Jakub Wilk.

- Added an option for afl-analyze to dump offsets in hex. Suggested by
Jakub Wilk.

- Added support for parameters in triage_crashes.sh. Patch by Adam of
DC949.

---------------------------
Version 2.51b (2017-08-30):
---------------------------

- Made afl-tmin call setsid to prevent glibc traceback junk from showing
up on the terminal in some distros. Suggested by Jakub Wilk.

---------------------------
Version 2.50b (2017-08-19):
---------------------------

- Fixed an interesting timing corner case spotted by Jakub Wilk.

- Addressed a libtokencap / pthreads incompatibility issue. Likewise, spotted
by Jakub Wilk.

- Added a mention of afl-kit and Pythia.

- Added AFL_FAST_CAL.

- In-place resume now preserves .synced. Suggested by Jakub Wilk.

---------------------------
Version 2.49b (2017-07-18):
---------------------------
Expand Down
Loading