aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-01-31 10:31:21 +0100
committerGitHub <noreply@github.com>2020-01-31 10:31:21 +0100
commite2618ab7c1cd30c7e94a07dd7356e1849cb2b973 (patch)
tree3f59e87d7d5fea8bbacf65c3f3829eda348ac40a
parent3b4920011b00a953751dfb8109974cc34ada755a (diff)
parent9f584e8cd91172423387c04a153887e8f5f8456c (diff)
downloadafl++-e2618ab7c1cd30c7e94a07dd7356e1849cb2b973.tar.gz
Merge pull request #179 from devnexen/cpu_binding_bsd_upd_proposal
fuzz init same fails and tries approach as Linux/Android.
-rw-r--r--src/afl-fuzz-init.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index 6efa6227..33b89a89 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -237,15 +237,32 @@ void bind_to_free_cpu(void) {
}
#elif defined(__FreeBSD__) || defined(__DragonFly__)
- if (pthread_setaffinity_np(pthread_self(), sizeof(c), &c))
- PFATAL("pthread_setaffinity failed");
+ if (pthread_setaffinity_np(pthread_self(), sizeof(c), &c)) {
+
+ if (cpu_start == cpu_core_count)
+ PFATAL("pthread_setaffinity failed for cpu %d, exit", i);
+ WARNF("pthread_setaffinity failed to CPU %d, trying next CPU", i);
+ cpu_start++;
+ goto try
+ ;
+
+ }
#elif defined(__NetBSD__)
-if (pthread_setaffinity_np(pthread_self(), cpuset_size(c), c))
- PFATAL("pthread_setaffinity failed");
+if (pthread_setaffinity_np(pthread_self(), cpuset_size(c), c)) {
+
+ if (cpu_start == cpu_core_count)
+ PFATAL("pthread_setaffinity failed for cpu %d, exit", i);
+ WARNF("pthread_setaffinity failed to CPU %d, trying next CPU", i);
+ cpu_start++;
+ goto try
+ ;
+
+}
cpuset_destroy(c);
#else
// this will need something for other platforms
+// TODO: Solaris/Illumos has processor_bind ... might worth a try
#endif
}