This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Preserve position hint in auto dictionary
ClosedPublic

Authored by fmeum on May 1 2021, 12:53 AM.

Details

Summary

Currently, the position hint of an entry in the persistent auto
dictionary is fixed to 1. As a consequence, with a 50% chance, the entry
is applied right after the first byte of the input. As the position 1
does not appear to have any particular significance, this is likely a
bug that may have been caused by confusing the constructor parameter
with a success count.

This commit resolves the issue by preserving any existing position hint
or disabling the hint if the original entry didn't have one.

Diff Detail

Event Timeline

fmeum requested review of this revision.May 1 2021, 12:53 AM
fmeum created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2021, 12:53 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
fmeum added inline comments.May 1 2021, 12:57 AM
compiler-rt/lib/fuzzer/FuzzerMutate.cpp
483

Maybe this can even be replaced by:

PersistentAutoDictionary.push_back(DE);

Or does the word in the entry need to be copied here?

Thanks for the bug fix!

compiler-rt/lib/fuzzer/FuzzerMutate.cpp
483

AFAICT, DictionaryEntry is POD, so yes let's just do push_back(DE) unconditionally.

fmeum updated this revision to Diff 342648.May 3 2021, 10:41 PM

Simplified the change by copying the DictionaryEntry POD.

This revision is now accepted and ready to land.May 4 2021, 8:49 AM
This revision was automatically updated to reflect the committed changes.