Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement on Deterministic stage #1972

Merged
merged 29 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
91d758e
fuzzer: init commit based on aflpp 60dc37a8cf09f8e9048e4b6a2204d6c90b…
kdsjZh Oct 27, 2023
94114a1
fuzzers: adding the skip variables and initialize
kdsjZh Oct 27, 2023
445d69e
log: profile the det/havoc finding
kdsjZh Oct 27, 2023
9ad112b
log: add profile log output
kdsjZh Oct 27, 2023
eb3be74
fuzzers: sperate log/skipdet module
kdsjZh Oct 28, 2023
f3b9d34
fuzzers: add quick eff_map calc
kdsjZh Oct 28, 2023
1d308b8
fuzzers: add skip_eff_map in fuzz_one
kdsjZh Oct 28, 2023
e1a81fa
fuzzers: mark whole input space in eff_map
kdsjZh Oct 28, 2023
87f5150
fuzzers: add undet bit threshold to skip some seeds
kdsjZh Oct 28, 2023
506f012
fuzzers: fix one byte overflow
kdsjZh Dec 5, 2023
ca4f62a
fuzzers: fix overflow
kdsjZh Dec 5, 2023
0da8de0
Merge remote-tracking branch 'vanilla/stable' into skip
kdsjZh Dec 15, 2023
d4e3ad5
Merge remote-tracking branch 'origin/skip' into dev_s
kdsjZh Jan 22, 2024
4e19bbc
Merge remote-tracking branch 'vanilla/dev' into dev_s
kdsjZh Jan 28, 2024
993119b
fix code format
kdsjZh Jan 28, 2024
debc7ec
add havoc only again
kdsjZh Jan 28, 2024
29ed854
code format
kdsjZh Jan 28, 2024
b2f7697
remove log to INTROSPECTION, rename skipdet module
kdsjZh Jan 28, 2024
97fcc69
rename skipdet module
kdsjZh Jan 28, 2024
915dd33
remove log to stats
kdsjZh Jan 28, 2024
9f9678c
clean redundant code
kdsjZh Jan 28, 2024
b713107
code format
kdsjZh Jan 28, 2024
e7717b7
remove redundant code format check
kdsjZh Jan 28, 2024
7c436c0
remove redundant doc
kdsjZh Jan 28, 2024
3f004b2
remove redundant objects
kdsjZh Jan 28, 2024
717b3b9
clean files
kdsjZh Jan 28, 2024
3cad907
change -d to default skipdet
kdsjZh Jan 29, 2024
cfd7355
disable deterministic when using CUSTOM_MUTATOR
kdsjZh Jan 29, 2024
c5303bb
revert fix
kdsjZh Jan 29, 2024
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
5 changes: 5 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ src/afl-forkserver.o : $(COMM_HDR) src/afl-forkserver.c include/forkserver.h
src/afl-sharedmem.o : $(COMM_HDR) src/afl-sharedmem.c include/sharedmem.h
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-sharedmem.c -o src/afl-sharedmem.o

src/afl-fuzz-skipdet.o : $(COMM_HDR) src/afl-fuzz-skipdet.c
kdsjZh marked this conversation as resolved.
Show resolved Hide resolved
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-fuzz-skipdet.c -o src/afl-fuzz-skipdet.o


afl-fuzz: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o | test_x86
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(PYFLAGS) $(LDFLAGS) -lm
kdsjZh marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -532,6 +536,7 @@ endif
.PHONY: code-format
code-format:
./.custom-format.py -i src/*.c
./.custom-format.py -i src/*.cc
kdsjZh marked this conversation as resolved.
Show resolved Hide resolved
./.custom-format.py -i include/*.h
./.custom-format.py -i instrumentation/*.h
./.custom-format.py -i instrumentation/*.cc
Expand Down
1 change: 1 addition & 0 deletions README.skip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is developed based on AFL++ 60dc37a8cf09f8e9048e4b6a2204d6c90b27655a
kdsjZh marked this conversation as resolved.
Show resolved Hide resolved
58 changes: 58 additions & 0 deletions include/afl-fuzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,48 @@ struct tainted {

};

struct inf_profile {

u32 inf_skipped_bytes; /* Inference Stage Profiling */
u64 inf_execs_cost, inf_time_cost;

};

/* ToDo: add cmplog profile as well */
struct havoc_profile {

u32 queued_det_stage, /* Det/Havoc Stage Profiling */
queued_havoc_stage, total_queued_det, edge_det_stage, edge_havoc_stage,
total_det_edge;

u64 det_stage_time, havoc_stage_time, total_det_time;

};

struct skipdet_entry {

u8 continue_inf, done_eff;
u32 undet_bits, quick_eff_bytes;

u8 *skip_eff_map, /* we'v finish the eff_map */
*done_inf_map; /* some bytes are not done yet */

};

struct skipdet_global {

u8 use_skip_havoc;

u32 undet_bits_threshold;

u64 last_cov_undet;

u8 *virgin_det_bits; /* global fuzzed bits */

struct inf_profile *inf_prof;

};

struct queue_entry {

u8 *fname; /* File name for the test case */
Expand Down Expand Up @@ -203,6 +245,8 @@ struct queue_entry {

struct queue_entry *mother; /* queue entry this based on */

struct skipdet_entry *skipdet_e;

};

struct extra_data {
Expand Down Expand Up @@ -247,6 +291,8 @@ enum {
/* 19 */ STAGE_CUSTOM_MUTATOR,
/* 20 */ STAGE_COLORIZATION,
/* 21 */ STAGE_ITS,
/* 22 */ STAGE_INF,
/* 23 */ STAGE_QUICK,

STAGE_NUM_MAX

Expand Down Expand Up @@ -782,6 +828,11 @@ typedef struct afl_state {
* is too large) */
struct queue_entry **q_testcase_cache;

/* Global Profile Data for deterministic/havoc-splice stage */
struct havoc_profile *havoc_prof;

struct skipdet_global *skipdet_g;

#ifdef INTROSPECTION
char mutation[8072];
char m_tmp[4096];
Expand Down Expand Up @@ -1232,6 +1283,13 @@ AFL_RAND_RETURN rand_next(afl_state_t *afl);
/* probability between 0.0 and 1.0 */
double rand_next_percent(afl_state_t *afl);

/* SkipDet Functions */

u8 skip_deterministic_stage(afl_state_t *, u8 *, u8 *, u32, u64);
u8 is_det_timeout(u64, u8);

void plot_profile_data(afl_state_t *, struct queue_entry *);

/**** Inline routines ****/

/* Generate a random number (from 0 to limit - 1). This may
Expand Down
12 changes: 12 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@
/* Default file permission umode when creating files (default: 0600) */
#define DEFAULT_PERMISSION 0600

/* SkipDet's global configuration */

#define MINIMAL_BLOCK_SIZE 64
#define SMALL_DET_TIME (60 * 1000 * 1000U)
#define MAXIMUM_INF_EXECS (16 * 1024U)
#define MAXIMUM_QUICK_EFF_EXECS (64 * 1024U)
#define THRESHOLD_DEC_TIME (20 * 60 * 1000U)

/* Set the Prob of selecting eff_bytes 3 times more than original,
Now disabled */
#define EFF_HAVOC_RATE 3

/* CMPLOG/REDQUEEN TUNING
*
* Here you can modify tuning and solving options for CMPLOG.
Expand Down
3 changes: 2 additions & 1 deletion include/forkserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ typedef struct afl_forkserver {
u8 *out_file, /* File to fuzz, if any */
*target_path; /* Path of the target */

FILE *plot_file; /* Gnuplot output file */
FILE *plot_file, /* Gnuplot output file */
*det_plot_file;

/* Note: last_run_timed_out is u32 to send it to the child as 4 byte array */
u32 last_run_timed_out; /* Traced process timed out? */
Expand Down
15 changes: 15 additions & 0 deletions src/afl-fuzz-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,21 @@ void setup_dirs_fds(afl_state_t *afl) {

fflush(afl->fsrv.plot_file);

#ifdef INTROSPECTION

tmp = alloc_printf("%s/plot_det_data", afl->out_dir);

int fd = open(tmp, O_WRONLY | O_CREAT, DEFAULT_PERMISSION);
if (fd < 0) { PFATAL("Unable to create '%s'", tmp); }
ck_free(tmp);

afl->fsrv.det_plot_file = fdopen(fd, "w");
if (!afl->fsrv.det_plot_file) { PFATAL("fdopen() failed"); }

if (afl->in_place_resume) { fseek(afl->fsrv.det_plot_file, 0, SEEK_END); }

#endif

/* ignore errors */

}
Expand Down
Loading
Loading