Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: third_party/afl/src/afl-fuzz.c

Issue 2662883002: Roll AFL 2.31b:2.38b and switch coverage to use trace-pc-guard. (Closed)
Patch Set: Remove unneeded vuln_samples binaries. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/afl/src/Makefile ('k') | third_party/afl/src/afl-gcc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 american fuzzy lop - fuzzer code 2 american fuzzy lop - fuzzer code
3 -------------------------------- 3 --------------------------------
4 4
5 Written and maintained by Michal Zalewski <lcamtuf@google.com> 5 Written and maintained by Michal Zalewski <lcamtuf@google.com>
6 6
7 Forkserver design by Jann Horn <jannhorn@googlemail.com> 7 Forkserver design by Jann Horn <jannhorn@googlemail.com>
8 8
9 Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved. 9 Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
10 10
(...skipping 3888 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 3899
3900 if (cur_ms - last_plot_ms > PLOT_UPDATE_SEC * 1000) { 3900 if (cur_ms - last_plot_ms > PLOT_UPDATE_SEC * 1000) {
3901 3901
3902 last_plot_ms = cur_ms; 3902 last_plot_ms = cur_ms;
3903 maybe_update_plot_file(t_byte_ratio, avg_exec); 3903 maybe_update_plot_file(t_byte_ratio, avg_exec);
3904 3904
3905 } 3905 }
3906 3906
3907 /* Honor AFL_EXIT_WHEN_DONE and AFL_BENCH_UNTIL_CRASH. */ 3907 /* Honor AFL_EXIT_WHEN_DONE and AFL_BENCH_UNTIL_CRASH. */
3908 3908
3909 if (!dumb_mode && cycles_wo_finds > 50 && !pending_not_fuzzed && 3909 if (!dumb_mode && cycles_wo_finds > 100 && !pending_not_fuzzed &&
3910 getenv("AFL_EXIT_WHEN_DONE")) stop_soon = 2; 3910 getenv("AFL_EXIT_WHEN_DONE")) stop_soon = 2;
3911 3911
3912 if (total_crashes && getenv("AFL_BENCH_UNTIL_CRASH")) stop_soon = 2; 3912 if (total_crashes && getenv("AFL_BENCH_UNTIL_CRASH")) stop_soon = 2;
3913 3913
3914 /* If we're not on TTY, bail out. */ 3914 /* If we're not on TTY, bail out. */
3915 3915
3916 if (not_on_tty) return; 3916 if (not_on_tty) return;
3917 3917
3918 /* Compute some mildly useful bitmap stats. */ 3918 /* Compute some mildly useful bitmap stats. */
3919 3919
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3973 if (dumb_mode) { 3973 if (dumb_mode) {
3974 3974
3975 strcpy(tmp, cRST); 3975 strcpy(tmp, cRST);
3976 3976
3977 } else { 3977 } else {
3978 3978
3979 /* First queue cycle: don't stop now! */ 3979 /* First queue cycle: don't stop now! */
3980 if (queue_cycle == 1) strcpy(tmp, cMGN); else 3980 if (queue_cycle == 1) strcpy(tmp, cMGN); else
3981 3981
3982 /* Subsequent cycles, but we're still making finds. */ 3982 /* Subsequent cycles, but we're still making finds. */
3983 if (cycles_wo_finds < 5) strcpy(tmp, cYEL); else 3983 if (cycles_wo_finds < 25) strcpy(tmp, cYEL); else
3984 3984
3985 /* No finds for a long time and no test cases to try. */ 3985 /* No finds for a long time and no test cases to try. */
3986 if (cycles_wo_finds > 50 && !pending_not_fuzzed) strcpy(tmp, cLGN); 3986 if (cycles_wo_finds > 100 && !pending_not_fuzzed) strcpy(tmp, cLGN);
3987 3987
3988 /* Default: cautiously OK to stop? */ 3988 /* Default: cautiously OK to stop? */
3989 else strcpy(tmp, cLBL); 3989 else strcpy(tmp, cLBL);
3990 3990
3991 } 3991 }
3992 3992
3993 SAYF(bV bSTOP " run time : " cRST "%-34s " bSTG bV bSTOP 3993 SAYF(bV bSTOP " run time : " cRST "%-34s " bSTG bV bSTOP
3994 " cycles done : %s%-5s " bSTG bV "\n", 3994 " cycles done : %s%-5s " bSTG bV "\n",
3995 DTD(cur_ms, start_time), tmp, DI(queue_cycle - 1)); 3995 DTD(cur_ms, start_time), tmp, DI(queue_cycle - 1));
3996 3996
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
4662 } 4662 }
4663 4663
4664 /* Final adjustment based on input depth, under the assumption that fuzzing 4664 /* Final adjustment based on input depth, under the assumption that fuzzing
4665 deeper test cases is more likely to reveal stuff that can't be 4665 deeper test cases is more likely to reveal stuff that can't be
4666 discovered with traditional fuzzers. */ 4666 discovered with traditional fuzzers. */
4667 4667
4668 switch (q->depth) { 4668 switch (q->depth) {
4669 4669
4670 case 0 ... 3: break; 4670 case 0 ... 3: break;
4671 case 4 ... 7: perf_score *= 2; break; 4671 case 4 ... 7: perf_score *= 2; break;
4672 case 8 ... 13: perf_score *= 4; break; 4672 case 8 ... 13: perf_score *= 3; break;
4673 case 14 ... 25: perf_score *= 6; break; 4673 case 14 ... 25: perf_score *= 4; break;
4674 default: perf_score *= 8; 4674 default: perf_score *= 5;
4675 4675
4676 } 4676 }
4677 4677
4678 /* Make sure that we don't go over limit. */ 4678 /* Make sure that we don't go over limit. */
4679 4679
4680 if (perf_score > HAVOC_MAX_MULT * 100) perf_score = HAVOC_MAX_MULT * 100; 4680 if (perf_score > HAVOC_MAX_MULT * 100) perf_score = HAVOC_MAX_MULT * 100;
4681 4681
4682 return perf_score; 4682 return perf_score;
4683 4683
4684 } 4684 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
4917 } else { 4917 } else {
4918 4918
4919 if (UR(100) < SKIP_NFAV_OLD_PROB) return 1; 4919 if (UR(100) < SKIP_NFAV_OLD_PROB) return 1;
4920 4920
4921 } 4921 }
4922 4922
4923 } 4923 }
4924 4924
4925 #endif /* ^IGNORE_FINDS */ 4925 #endif /* ^IGNORE_FINDS */
4926 4926
4927 if (not_on_tty) 4927 if (not_on_tty) {
4928 ACTF("Fuzzing test case #%u (%u total)...", current_entry, queued_paths); 4928 ACTF("Fuzzing test case #%u (%u total, %llu uniq crashes found)...",
4929 current_entry, queued_paths, unique_crashes);
4930 fflush(stdout);
4931 }
4929 4932
4930 /* Map the test case into memory. */ 4933 /* Map the test case into memory. */
4931 4934
4932 fd = open(queue_cur->fname, O_RDONLY); 4935 fd = open(queue_cur->fname, O_RDONLY);
4933 4936
4934 if (fd < 0) PFATAL("Unable to open '%s'", queue_cur->fname); 4937 if (fd < 0) PFATAL("Unable to open '%s'", queue_cur->fname);
4935 4938
4936 len = queue_cur->len; 4939 len = queue_cur->len;
4937 4940
4938 orig_in = in_buf = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); 4941 orig_in = in_buf = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
6915 6918
6916 } 6919 }
6917 6920
6918 6921
6919 /* Check if we're on TTY. */ 6922 /* Check if we're on TTY. */
6920 6923
6921 static void check_if_tty(void) { 6924 static void check_if_tty(void) {
6922 6925
6923 struct winsize ws; 6926 struct winsize ws;
6924 6927
6928 if (getenv("AFL_NO_UI")) {
6929 OKF("Disabling the UI because AFL_NO_UI is set.");
6930 not_on_tty = 1;
6931 return;
6932 }
6933
6925 if (ioctl(1, TIOCGWINSZ, &ws)) { 6934 if (ioctl(1, TIOCGWINSZ, &ws)) {
6926 6935
6927 if (errno == ENOTTY) { 6936 if (errno == ENOTTY) {
6928 OKF("Looks like we're not running on a tty, so I'll be a bit less verbose. "); 6937 OKF("Looks like we're not running on a tty, so I'll be a bit less verbose. ");
6929 not_on_tty = 1; 6938 not_on_tty = 1;
6930 } 6939 }
6931 6940
6932 return; 6941 return;
6933 } 6942 }
6934 6943
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
7301 cur_runnable = (u32)get_runnable_processes(); 7310 cur_runnable = (u32)get_runnable_processes();
7302 7311
7303 #if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__) 7312 #if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__)
7304 7313
7305 /* Add ourselves, since the 1-minute average doesn't include that yet. */ 7314 /* Add ourselves, since the 1-minute average doesn't include that yet. */
7306 7315
7307 cur_runnable++; 7316 cur_runnable++;
7308 7317
7309 #endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */ 7318 #endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */
7310 7319
7311 OKF("You have %u CPU cores and %u runnable tasks (utilization: %0.0f%%).", 7320 OKF("You have %u CPU core%s and %u runnable tasks (utilization: %0.0f%%).",
7312 cpu_core_count, cur_runnable, cur_runnable * 100.0 / cpu_core_count); 7321 cpu_core_count, cpu_core_count > 1 ? "s" : "",
7322 cur_runnable, cur_runnable * 100.0 / cpu_core_count);
7313 7323
7314 if (cpu_core_count > 1) { 7324 if (cpu_core_count > 1) {
7315 7325
7316 if (cur_runnable > cpu_core_count * 1.5) { 7326 if (cur_runnable > cpu_core_count * 1.5) {
7317 7327
7318 WARNF("System under apparent load, performance may be spotty."); 7328 WARNF("System under apparent load, performance may be spotty.");
7319 7329
7320 } else if (cur_runnable + 1 <= cpu_core_count) { 7330 } else if (cur_runnable + 1 <= cpu_core_count) {
7321 7331
7322 OKF("Try parallel jobs - see %s/parallel_fuzzing.txt.", doc_path); 7332 OKF("Try parallel jobs - see %s/parallel_fuzzing.txt.", doc_path);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
7645 7655
7646 if (out_dir) FATAL("Multiple -o options not supported"); 7656 if (out_dir) FATAL("Multiple -o options not supported");
7647 out_dir = optarg; 7657 out_dir = optarg;
7648 break; 7658 break;
7649 7659
7650 case 'M': { /* master sync ID */ 7660 case 'M': { /* master sync ID */
7651 7661
7652 u8* c; 7662 u8* c;
7653 7663
7654 if (sync_id) FATAL("Multiple -S or -M options not supported"); 7664 if (sync_id) FATAL("Multiple -S or -M options not supported");
7655 sync_id = optarg; 7665 sync_id = ck_strdup(optarg);
7656 7666
7657 if ((c = strchr(sync_id, ':'))) { 7667 if ((c = strchr(sync_id, ':'))) {
7658 7668
7659 *c = 0; 7669 *c = 0;
7660 7670
7661 if (sscanf(c + 1, "%u/%u", &master_id, &master_max) != 2 || 7671 if (sscanf(c + 1, "%u/%u", &master_id, &master_max) != 2 ||
7662 !master_id || !master_max || master_id > master_max || 7672 !master_id || !master_max || master_id > master_max ||
7663 master_max > 1000000) FATAL("Bogus master ID passed to -M"); 7673 master_max > 1000000) FATAL("Bogus master ID passed to -M");
7664 7674
7665 } 7675 }
7666 7676
7667 force_deterministic = 1; 7677 force_deterministic = 1;
7668 7678
7669 } 7679 }
7670 7680
7671 break; 7681 break;
7672 7682
7673 case 'S': 7683 case 'S':
7674 7684
7675 if (sync_id) FATAL("Multiple -S or -M options not supported"); 7685 if (sync_id) FATAL("Multiple -S or -M options not supported");
7676 sync_id = optarg; 7686 sync_id = ck_strdup(optarg);
7677 break; 7687 break;
7678 7688
7679 case 'f': /* target file */ 7689 case 'f': /* target file */
7680 7690
7681 if (out_file) FATAL("Multiple -f options not supported"); 7691 if (out_file) FATAL("Multiple -f options not supported");
7682 out_file = optarg; 7692 out_file = optarg;
7683 break; 7693 break;
7684 7694
7685 case 'x': /* dictionary */ 7695 case 'x': /* dictionary */
7686 7696
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
7975 SAYF("\n" cYEL "[!] " cRST 7985 SAYF("\n" cYEL "[!] " cRST
7976 "Stopped during the first cycle, results may be incomplete.\n" 7986 "Stopped during the first cycle, results may be incomplete.\n"
7977 " (For info on resuming, see %s/README.)\n", doc_path); 7987 " (For info on resuming, see %s/README.)\n", doc_path);
7978 7988
7979 } 7989 }
7980 7990
7981 fclose(plot_file); 7991 fclose(plot_file);
7982 destroy_queue(); 7992 destroy_queue();
7983 destroy_extras(); 7993 destroy_extras();
7984 ck_free(target_path); 7994 ck_free(target_path);
7995 ck_free(sync_id);
7985 7996
7986 alloc_report(); 7997 alloc_report();
7987 7998
7988 OKF("We're done here. Have a nice day!\n"); 7999 OKF("We're done here. Have a nice day!\n");
7989 8000
7990 exit(0); 8001 exit(0);
7991 8002
7992 } 8003 }
7993 8004
7994 #endif /* !AFL_LIB */ 8005 #endif /* !AFL_LIB */
OLDNEW
« no previous file with comments | « third_party/afl/src/Makefile ('k') | third_party/afl/src/afl-gcc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698