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

Fix double crash for solutions with the same filename (#1232) #1236

Merged
merged 6 commits into from
Apr 29, 2023

Conversation

tokatoka
Copy link
Member

No description provided.

@@ -304,7 +305,13 @@ where
fn save_testcase(&self, testcase: &mut Testcase<I>, idx: CorpusId) -> Result<(), Error> {
let file_name_orig = testcase.filename_mut().take().unwrap_or_else(|| {
// TODO walk entry metadata to ask for pieces of filename (e.g. :havoc in AFL)
testcase.input().as_ref().unwrap().generate_name(idx.0)
let mut hasher = ahash::RandomState::with_seeds(0, 0, 0, 0).build_hasher();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why always create the hasher, even when it's not used inside the function? Seems wasteful and somewhat pointless?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate_name() should use it.

generate_name(idx.0, &mut hasher)

Copy link
Member

@domenukk domenukk Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't always? Why not create the hasher inside if you need it? Imho an ideal name shouldn't be random, but log the mutations etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nautilus doesn't use it for example

Copy link
Member Author

@tokatoka tokatoka Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of putting hasher into the argument is to making it clear it is suggested to use hasher to make the testcase names random.
#1232 (comment)

Imho an ideal name shouldn't be random, but log the mutations etc.

Yup, like afl, but not all mutators log the mutation result

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's a good solution, just adding a comment should be better. No need to change the API imho.
That being said, we can also consider having one corpus folder for each core somehow

Copy link
Member Author

@tokatoka tokatoka Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm ok

That being said, we can also consider having one corpus folder for each core somehow

in tlspuffin's case there were 25 testcases with the same name, while there were only 8 cores fuzzing. I don't know what happened, separating folder is fine but it's not enough in this case.

I think the problem is https://github.com/AFLplusplus/LibAFL/blob/main/libafl/src/corpus/inmemory_ondisk.rs#L316
this counter. It's easy to have clashing names if you monotonously increase it.

How do you think about putting the current time in nano sec instead of a simple counter here? then very little chance to have the same name unless the testcases are stored at the very same nano second

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's something that tlspuffin should do

@domenukk domenukk changed the title Fix #1232 Fix double crash for solutions with the same filename (#1232) Apr 28, 2023
@domenukk domenukk merged commit b2f9e23 into main Apr 29, 2023
@domenukk domenukk deleted the fix_inmemondisk branch April 29, 2023 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants