Skip to content

Commit 2fb5a34

Browse files
committed
2.52b
1 parent 007fa4e commit 2fb5a34

17 files changed

+224
-133
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Written and maintained by Michal Zalewski <[email protected]>
66
#
7-
# Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
7+
# Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. All rights reserved.
88
#
99
# Licensed under the Apache License, Version 2.0 (the "License");
1010
# you may not use this file except in compliance with the License.
@@ -111,8 +111,8 @@ all_done: test_build
111111
.NOTPARALLEL: clean
112112

113113
clean:
114-
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
115-
rm -rf out_dir qemu_mode/qemu-2.3.0
114+
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.10.0.tar.bz2 afl-qemu-trace
115+
rm -rf out_dir qemu_mode/qemu-2.10.0
116116
$(MAKE) -C llvm_mode clean
117117
$(MAKE) -C libdislocator clean
118118
$(MAKE) -C libtokencap clean

afl-analyze.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Written and maintained by Michal Zalewski <[email protected]>
66
7-
Copyright 2016 Google Inc. All rights reserved.
7+
Copyright 2016, 2017 Google Inc. All rights reserved.
88
99
Licensed under the Apache License, Version 2.0 (the "License");
1010
you may not use this file except in compliance with the License.
@@ -68,6 +68,7 @@ static s32 shm_id, /* ID of the SHM region */
6868
dev_null_fd = -1; /* FD to /dev/null */
6969

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

7374
static volatile u8
@@ -486,9 +487,13 @@ static void dump_hex(u8* buf, u32 len, u8* b_data) {
486487
/* Every 16 digits, display offset. */
487488

488489
if (!((i + off) % 16)) {
489-
490+
490491
if (off) SAYF(cRST cLCY ">");
491-
SAYF(cRST cGRA "%s[%06u] " cRST, (i + off) ? "\n" : "", i + off);
492+
493+
if (use_hex_offsets)
494+
SAYF(cRST cGRA "%s[%06x] " cRST, (i + off) ? "\n" : "", i + off);
495+
else
496+
SAYF(cRST cGRA "%s[%06u] " cRST, (i + off) ? "\n" : "", i + off);
492497

493498
}
494499

@@ -512,7 +517,10 @@ static void dump_hex(u8* buf, u32 len, u8* b_data) {
512517

513518
#else
514519

515-
SAYF(" Offset %u, length %u: ", i, rlen);
520+
if (use_hex_offsets)
521+
SAYF(" Offset %x, length %u: ", i, rlen);
522+
else
523+
SAYF(" Offset %u, length %u: ", i, rlen);
516524

517525
switch (rtype) {
518526

@@ -874,6 +882,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
874882
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
875883
u8 *tmp, *cp, *rsl, *own_copy;
876884

885+
/* Workaround for a QEMU stability glitch. */
886+
887+
setenv("QEMU_LOG", "nochain", 1);
888+
877889
memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
878890

879891
/* Now we need to actually find qemu for argv[0]. */
@@ -1026,6 +1038,8 @@ int main(int argc, char** argv) {
10261038

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

1041+
use_hex_offsets = !!getenv("AFL_ANALYZE_HEX");
1042+
10291043
setup_shm();
10301044
setup_signal_handlers();
10311045

afl-fuzz.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Forkserver design by Jann Horn <[email protected]>
88
9-
Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
9+
Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. All rights reserved.
1010
1111
Licensed under the Apache License, Version 2.0 (the "License");
1212
you may not use this file except in compliance with the License.
@@ -121,6 +121,7 @@ EXP_ST u8 skip_deterministic, /* Skip deterministic stages? */
121121
skip_requested, /* Skip request, via SIGUSR1 */
122122
run_over10m, /* Run time over 10 minutes? */
123123
persistent_mode, /* Running in persistent mode? */
124+
deferred_mode, /* Deferred forkserver mode? */
124125
fast_cal; /* Try to calibrate faster? */
125126

126127
static s32 out_fd, /* Persistent fd for out_file */
@@ -3428,6 +3429,7 @@ static void write_stats_file(double bitmap_cvg, double stability, double eps) {
34283429
"exec_timeout : %u\n"
34293430
"afl_banner : %s\n"
34303431
"afl_version : " VERSION "\n"
3432+
"target_mode : %s%s%s%s%s%s%s\n"
34313433
"command_line : %s\n",
34323434
start_time / 1000, get_cur_time() / 1000, getpid(),
34333435
queue_cycle ? (queue_cycle - 1) : 0, total_execs, eps,
@@ -3436,7 +3438,13 @@ static void write_stats_file(double bitmap_cvg, double stability, double eps) {
34363438
queued_variable, stability, bitmap_cvg, unique_crashes,
34373439
unique_hangs, last_path_time / 1000, last_crash_time / 1000,
34383440
last_hang_time / 1000, total_execs - last_crash_execs,
3439-
exec_tmout, use_banner, orig_cmdline);
3441+
exec_tmout, use_banner,
3442+
qemu_mode ? "qemu " : "", dumb_mode ? " dumb " : "",
3443+
no_forkserver ? "no_forksrv " : "", crash_mode ? "crash " : "",
3444+
persistent_mode ? "persistent " : "", deferred_mode ? "deferred " : "",
3445+
(qemu_mode || dumb_mode || no_forkserver || crash_mode ||
3446+
persistent_mode || deferred_mode) ? "" : "default",
3447+
orig_cmdline);
34403448
/* ignore errors */
34413449

34423450
fclose(f);
@@ -6946,6 +6954,7 @@ EXP_ST void check_binary(u8* fname) {
69466954

69476955
OKF(cPIN "Deferred forkserver binary detected.");
69486956
setenv(DEFER_ENV_VAR, "1", 1);
6957+
deferred_mode = 1;
69496958

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

@@ -7596,6 +7605,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
75967605
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
75977606
u8 *tmp, *cp, *rsl, *own_copy;
75987607

7608+
/* Workaround for a QEMU stability glitch. */
7609+
7610+
setenv("QEMU_LOG", "nochain", 1);
7611+
75997612
memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
76007613

76017614
new_argv[2] = target_path;

afl-showmap.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Written and maintained by Michal Zalewski <[email protected]>
66
7-
Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
7+
Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. All rights reserved.
88
99
Licensed under the Apache License, Version 2.0 (the "License");
1010
you may not use this file except in compliance with the License.
@@ -293,6 +293,8 @@ static void run_target(char** argv) {
293293

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

296+
setsid();
297+
296298
execv(target_path, argv);
297299

298300
*(u32*)trace_bits = EXEC_FAIL_SIG;
@@ -557,6 +559,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
557559
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
558560
u8 *tmp, *cp, *rsl, *own_copy;
559561

562+
/* Workaround for a QEMU stability glitch. */
563+
564+
setenv("QEMU_LOG", "nochain", 1);
565+
560566
memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
561567

562568
new_argv[2] = target_path;

afl-tmin.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Written and maintained by Michal Zalewski <[email protected]>
66
7-
Copyright 2015, 2016 Google Inc. All rights reserved.
7+
Copyright 2015, 2016, 2017 Google Inc. All rights reserved.
88
99
Licensed under the Apache License, Version 2.0 (the "License");
1010
you may not use this file except in compliance with the License.
@@ -341,8 +341,11 @@ static u8 run_target(char** argv, u8* mem, u32 len, u8 first_run) {
341341
total_execs++;
342342

343343
if (stop_soon) {
344+
344345
SAYF(cRST cLRD "\n+++ Minimization aborted by user +++\n" cRST);
346+
close(write_to_file(out_file, in_data, in_len));
345347
exit(1);
348+
346349
}
347350

348351
/* Always discard inputs that time out. */
@@ -891,6 +894,10 @@ static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
891894
char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
892895
u8 *tmp, *cp, *rsl, *own_copy;
893896

897+
/* Workaround for a QEMU stability glitch. */
898+
899+
setenv("QEMU_LOG", "nochain", 1);
900+
894901
memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
895902

896903
/* Now we need to actually find qemu for argv[0]. */

config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/* Version string: */
2323

24-
#define VERSION "2.51b"
24+
#define VERSION "2.52b"
2525

2626
/******************************************************
2727
* *

docs/ChangeLog

+21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@ Not sure if you should upgrade? The lowest currently recommended version
1616
is 2.41b. If you're stuck on an earlier release, it's strongly advisable
1717
to get on with the times.
1818

19+
---------------------------
20+
Version 2.52b (2017-11-04):
21+
---------------------------
22+
23+
- Upgraded QEMU patches from 2.3.0 to 2.10.0. Required troubleshooting
24+
several weird issues. All the legwork done by Andrew Griffiths.
25+
26+
- Added setsid to afl-showmap. See the notes for 2.51b.
27+
28+
- Added target mode (deferred, persistent, qemu, etc) to fuzzer_stats.
29+
Requested by Jakub Wilk.
30+
31+
- afl-tmin should now save a partially minimized file when Ctrl-C
32+
is pressed. Suggested by Jakub Wilk.
33+
34+
- Added an option for afl-analyze to dump offsets in hex. Suggested by
35+
Jakub Wilk.
36+
37+
- Added support for parameters in triage_crashes.sh. Patch by Adam of
38+
DC949.
39+
1940
---------------------------
2041
Version 2.51b (2017-08-30):
2142
---------------------------

docs/env_variables.txt

+10-4
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,13 @@ to match when minimizing crashes. This will make minimization less useful, but
213213
may prevent the tool from "jumping" from one crashing condition to another in
214214
very buggy software. You probably want to combine it with the -e flag.
215215

216-
7) Settings for libdislocator.so
216+
7) Settings for afl-analyze
217+
---------------------------
218+
219+
You can set AFL_ANALYZE_HEX to get file offsets printed as hexadecimal instead
220+
of decimal.
221+
222+
8) Settings for libdislocator.so
217223
--------------------------------
218224

219225
The library honors three environmental variables:
@@ -233,14 +239,14 @@ The library honors three environmental variables:
233239
of the common allocators check for that internally and return NULL, so
234240
it's a security risk only in more exotic setups.
235241

236-
8) Settings for libtokencap.so
242+
9) Settings for libtokencap.so
237243
------------------------------
238244

239245
This library accepts AFL_TOKEN_FILE to indicate the location to which the
240246
discovered tokens should be written.
241247

242-
9) Third-party variables set by afl-fuzz & other tools
243-
------------------------------------------------------
248+
10) Third-party variables set by afl-fuzz & other tools
249+
-------------------------------------------------------
244250

245251
Several variables are not directly interpreted by afl-fuzz, but are set to
246252
optimal values if not already present in the environment:

docs/status_screen.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ wait a couple of cycles to get their chance).
297297

298298
Next, we have the number of new paths found during this fuzzing section and
299299
imported from other fuzzer instances when doing parallelized fuzzing; and the
300-
number of inputs that produce seemingly variable behavior in the tested binary.
300+
extent to which identical inputs appear to sometimes produce variable behavior
301+
in the tested binary.
301302

302303
That last bit is actually fairly interesting: it measures the consistency of
303304
observed traces. If a program always behaves the same for the same input data,

experimental/crash_triage/triage_crashes.sh

+29-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Written and maintained by Michal Zalewski <[email protected]>
77
#
8-
# Copyright 2013, 2014 Google Inc. All rights reserved.
8+
# Copyright 2013, 2014, 2017 Google Inc. All rights reserved.
99
#
1010
# Licensed under the Apache License, Version 2.0 (the "License");
1111
# you may not use this file except in compliance with the License.
@@ -28,18 +28,16 @@ echo
2828
ulimit -v 100000 2>/dev/null
2929
ulimit -d 100000 2>/dev/null
3030

31-
if [ ! "$#" = "2" ]; then
32-
echo "Usage: $0 /path/to/afl_output_dir /path/to/tested_binary" 1>&2
33-
echo 1>&2
34-
echo "Note: the tested binary must accept input on stdin and require no additional" 1>&2
35-
echo "parameters. For more complex use cases, you need to edit this script." 1>&2
31+
if [ "$#" -lt "2" ]; then
32+
echo "Usage: $0 /path/to/afl_output_dir /path/to/tested_binary [...target params...]" 1>&2
3633
echo 1>&2
3734
exit 1
3835
fi
3936

4037
DIR="$1"
4138
BIN="$2"
42-
39+
shift
40+
shift
4341

4442
if [ "$AFL_ALLOW_TMP" = "" ]; then
4543

@@ -85,11 +83,33 @@ for crash in $DIR/crashes/id:*; do
8583
id=`basename -- "$crash" | cut -d, -f1 | cut -d: -f2`
8684
sig=`basename -- "$crash" | cut -d, -f2 | cut -d: -f2`
8785

86+
# Grab the args, converting @@ to $crash
87+
88+
use_args=""
89+
use_stdio=1
90+
91+
for a in $@; do
92+
93+
if [ "$a" = "@@" ] ; then
94+
args="$use_args $crash"
95+
unset use_stdio
96+
else
97+
args="$use_args $a"
98+
fi
99+
100+
done
101+
102+
# Strip the trailing space
103+
use_args="${use_args# }"
104+
88105
echo "+++ ID $id, SIGNAL $sig +++"
89106
echo
90107

91-
$GDB --batch -q --ex "r <$crash" --ex 'back' --ex 'disass $pc, $pc+16' --ex 'info reg' --ex 'quit' "$BIN" 0</dev/null
108+
if [ "$use_stdio" = "1" ]; then
109+
$GDB --batch -q --ex "r $use_args <$crash" --ex 'back' --ex 'disass $pc, $pc+16' --ex 'info reg' --ex 'quit' "$BIN" 0</dev/null
110+
else
111+
$GDB --batch -q --ex "r $use_args" --ex 'back' --ex 'disass $pc, $pc+16' --ex 'info reg' --ex 'quit' "$BIN" 0</dev/null
112+
fi
92113
echo
93114

94115
done
95-

qemu_mode/README.qemu

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The idea and much of the implementation comes from Andrew Griffiths.
2121
2) How to use
2222
-------------
2323

24-
The feature is implemented with a fairly simple patch to QEMU 2.3.0. The
24+
The feature is implemented with a fairly simple patch to QEMU 2.10.0. The
2525
simplest way to build it is to run ./build_qemu_support.sh. The script will
2626
download, configure, and compile the QEMU binary for you.
2727

0 commit comments

Comments
 (0)