This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 649
Search for other free cores when bind fails #68
Open
qlyoung
wants to merge
1
commit into
google:master
Choose a base branch
from
qlyoung:afl-continue-core-search
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,30 +488,63 @@ static void bind_to_free_cpu(void) { | |
|
||
closedir(d); | ||
|
||
for (i = 0; i < cpu_core_count; i++) if (!cpu_used[i]) break; | ||
|
||
if (i == cpu_core_count) { | ||
int bound = 0; | ||
int tried_bind = 0; | ||
int saved_errno = 0; | ||
|
||
SAYF("\n" cLRD "[-] " cRST | ||
"Uh-oh, looks like all %u CPU cores on your system are allocated to\n" | ||
" other instances of afl-fuzz (or similar CPU-locked tasks). Starting\n" | ||
" another fuzzer on this machine is probably a bad plan, but if you are\n" | ||
" absolutely sure, you can set AFL_NO_AFFINITY and try again.\n", | ||
cpu_core_count); | ||
for (i = 0; i < cpu_core_count; i++) { | ||
|
||
if (!cpu_used[i]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's decrease the indentation by inverting the condition:
|
||
|
||
OKF("Found a free CPU core, attempting bind to #%u.", i); | ||
|
||
CPU_ZERO(&c); | ||
CPU_SET(i, &c); | ||
|
||
if (sched_setaffinity(0, sizeof(c), &c)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar suggestion here: if (!sched_setaffinity(0, sizeof(c), &c)) {
cpu_aff = i;
bound = 1;
break;
}
saved_errno = errno;
tried_bind++;
WARNF("Binding attempt failed; looking for another core..."); |
||
|
||
FATAL("No more free CPU cores"); | ||
saved_errno = errno; | ||
tried_bind++; | ||
WARNF("Binding attempt failed; looking for another core..."); | ||
|
||
} else { | ||
|
||
cpu_aff = i; | ||
bound = 1; | ||
break; | ||
|
||
} | ||
} | ||
} | ||
|
||
OKF("Found a free CPU core, binding to #%u.", i); | ||
if (!bound) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...
if (bound)
return;
<error reporting code here>
} |
||
|
||
cpu_aff = i; | ||
if (tried_bind == 0) { | ||
|
||
CPU_ZERO(&c); | ||
CPU_SET(i, &c); | ||
SAYF("\n" cLRD "[-] " cRST | ||
"Uh-oh, looks like all %u CPU cores on your system are allocated to\n" | ||
" other instances of afl-fuzz (or similar CPU-locked tasks). Starting\n" | ||
" another fuzzer on this machine is probably a bad plan, but if you are\n" | ||
" absolutely sure, you can set AFL_NO_AFFINITY and try again.\n\n", | ||
cpu_core_count); | ||
FATAL("No more free CPU cores"); | ||
|
||
if (sched_setaffinity(0, sizeof(c), &c)) | ||
PFATAL("sched_setaffinity failed"); | ||
} else { | ||
|
||
SAYF("\n" cLRD "[-] " cRST | ||
"Uh-oh, afl-fuzz found %u apparently free CPU cores, but the system\n" | ||
" wouldn't let us bind to any of them. This can happen if we do not\n" | ||
" have CAP_SYS_NICE, or if we are running in a container that is\n" | ||
" restricted to a certain set of CPUs that already have processes bound\n" | ||
" to them. For a quick workaround, set AFL_NO_AFFINITY and try again.\n", | ||
tried_bind); | ||
|
||
errno = saved_errno; | ||
PFATAL("sched_setaffinity failed"); | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to
bind_attempts