diff options
Diffstat (limited to 'src/afl-fuzz-init.c')
-rw-r--r-- | src/afl-fuzz-init.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 127f5217..82ba6f8a 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -2,7 +2,7 @@ american fuzzy lop++ - initialization related routines ------------------------------------------------------ - Originally written by Michal Zalewski <lcamtuf@google.com> + Originally written by Michal Zalewski Now maintained by by Marc Heuse <mh@mh-sec.de>, Heiko Eißfeldt <heiko.eissfeldt@hexco.de> and @@ -32,7 +32,7 @@ void bind_to_free_cpu(void) { -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) cpu_set_t c; #elif defined(__NetBSD__) cpuset_t* c; @@ -117,7 +117,7 @@ void bind_to_free_cpu(void) { } closedir(d); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) struct kinfo_proc* procs; size_t nprocs; size_t proccount; @@ -138,7 +138,13 @@ void bind_to_free_cpu(void) { for (i = 0; i < proccount; i++) { - if (procs[i].ki_oncpu < sizeof(cpu_used)) cpu_used[procs[i].ki_oncpu] = 1; +#if defined(__FreeBSD__) + if (procs[i].ki_oncpu < sizeof(cpu_used) && procs[i].ki_pctcpu > 10) + cpu_used[procs[i].ki_oncpu] = 1; +#elif defined(__DragonFly__) + if (procs[i].kp_lwp.kl_cpuid < sizeof(cpu_used) && procs[i].kp_lwp.kl_pctcpu > 10) + cpu_used[procs[i].kp_lwp.kl_cpuid] = 1; +#endif } @@ -166,7 +172,8 @@ void bind_to_free_cpu(void) { for (i = 0; i < proccount; i++) { - if (procs[i].p_cpuid < sizeof(cpu_used)) cpu_used[procs[i].p_cpuid] = 1; + if (procs[i].p_cpuid < sizeof(cpu_used) && procs[i].p_pctcpu > 0) + cpu_used[procs[i].p_cpuid] = 1; } @@ -198,7 +205,7 @@ void bind_to_free_cpu(void) { cpu_aff = i; -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) CPU_ZERO(&c); CPU_SET(i, &c); #elif defined(__NetBSD__) @@ -210,7 +217,7 @@ void bind_to_free_cpu(void) { #if defined(__linux__) if (sched_setaffinity(0, sizeof(c), &c)) PFATAL("sched_setaffinity failed"); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) if (pthread_setaffinity_np(pthread_self(), sizeof(c), &c)) PFATAL("pthread_setaffinity failed"); #elif defined(__NetBSD__) @@ -727,7 +734,7 @@ void pivot_inputs(void) { use_name += 6; else use_name = rsl; - nfn = alloc_printf("%s/queue/id:%06u,orig:%s", out_dir, id, use_name); + nfn = alloc_printf("%s/queue/id:%06u,time:0,orig:%s", out_dir, id, use_name); #else @@ -869,7 +876,7 @@ double get_runnable_processes(void) { static double res; #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ - defined(__NetBSD__) + defined(__NetBSD__) || defined(__DragonFly__) /* I don't see any portable sysctl or so that would quickly give us the number of runnable processes; the 1-minute load average can be a @@ -1603,7 +1610,7 @@ void check_cpu_governor(void) { void get_core_count(void) { -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) size_t s = sizeof(cpu_core_count); @@ -1649,7 +1656,7 @@ void get_core_count(void) { cur_runnable = (u32)get_runnable_processes(); -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) /* Add ourselves, since the 1-minute average doesn't include that yet. */ |