fix(AflppRedQueen): fix u64 I2S mutation and allow variable-length FnOperands#3741
Open
drewbarbs wants to merge 2 commits intoAFLplusplus:mainfrom
Open
fix(AflppRedQueen): fix u64 I2S mutation and allow variable-length FnOperands#3741drewbarbs wants to merge 2 commits intoAFLplusplus:mainfrom
drewbarbs wants to merge 2 commits intoAFLplusplus:mainfrom
Conversation
When the RQ mutator sees that a 8 byte comparison operand is equal to 8 bytes from the input, then it treats that as an I2S correspondence and pushes a mutation that replaces those input bytes with a big-endian encoding of the second comparison operand, `repl` (this process is done on both the original/byte-swapped versions of the relevant values, to handle either byte order) This commit fixes a bit shifting bug (probably typo) that breaks the replacement by repeating one byte and dropping the most significant byte, which makes RQ unable to solve the comparison.
AflppCmpLogFnOperands has fixed length (`[u8; 32]`) storage for `v0` and
`v1`, and separate `v0_len`/`v1_len` fields. However, the rust
constructor/setters only allow for `v0`/`v1` to be initialized from
slices that are _exactly_ 32 bytes long, since `copy_from_slice` panics
otherwise. So `v0_len`/`v1_len` can only be 32. The instrumentation in
`libafl_targets`' `cmplog.{h,c}` can create log entries where the
`v0_len`/`v1_len` values are anywhere between 0 and 32, so this change
allows us to do the same from rust.
Note: in LibAFL's cmplog instrumentation, `v0_len`/`v1_len` are
always _the same_ value. In AFLplusplus' implementation,
`__cmplog_rtn_hook_str` can create log entries with `v0_len !=
v1_len`.
960e2e0 to
0fecd57
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
These are a couple of small fixes to the Aflpp RedQueen implementation:
fix AflppRedQueen mutator's u64 I2S replacement
When the RQ mutator sees that a 8 byte comparison operand is equal to 8 bytes from the input, then it treats that as an I2S correspondence and pushes a mutation that replaces those input bytes with a big-endian encoding of the second comparison operand,
repl(this process is done on both the original/byte-swapped versions of the relevant values, to handle either byte order)This commit fixes a bit shifting bug (probably typo) that breaks the replacement by repeating one byte and dropping the most significant byte, which makes RQ unable to solve the comparison.
fix
AflppCmpLogFnOperands::newto allow v0/v1 with different lengthsAflppCmpLogFnOperands has fixed length (
[u8; 32]) storage forv0andv1, and separatev0_len/v1_lenfields. However, the rust constructor/setters only allow forv0/v1to be initialized from slices that are exactly 32 bytes long, sincecopy_from_slicepanics otherwise. Sov0_len/v1_lencan only be 32. The instrumentation inlibafl_targets'cmplog.{h,c}can create log entries where thev0_len/v1_lenvalues are anywhere between 0 and 32, and this change allows us to do the same from rust.Note: in LibAFL's cmplog instrumentation,
v0_len/v1_lenare always the same value. In AFLplusplus' implementation,__cmplog_rtn_hook_strcan create log entries withv0_len != v1_len, which this change also allows.Checklist
./scripts/precommit.shand addressed all comments