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

Added experimental Compcov/LAF support for the Bochs backend #186

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m4drat
Copy link

@m4drat m4drat commented Oct 12, 2023

Hi!
This summer I've worked on adding LAF/Compcov support for WTF. This pull-request is the essence of this experiment. I tried to make the code as "production"-ready as possible but I'm sure there is still a long way to go. I'm sending this PR because at the moment I don't have any time to work on it any further.

LAF/Compcov mode allows to solve some basic CMP-related fuzz-blockers by splitting them into multiple comparisons of smaller sizes. With the proposed implementation of the LAF/Compcov mode, WTF was able to solve all the challenges from this "benchmark": fuzzy_goat.cc and crash the program:
wtf-laf-found-crash

An alternative implementations of this technique can be found in the qemuafl's source code: qemuafl/cpu-translate.h

I did some basic evaluation of the proposed approach (only on one target - rizin), and it kinda works but honestly speaking I was expecting a little bit more :) (maybe if it's tested on other targets it will show better results but who knows).

All the experimental-evaluation stuff can be found in the ./scripts/ folder. The experiment I've conducted consisted of running a bunch of WTF instances with and w/o the LAF/Compcov mode. To be precise, I had 2 instances running with LAF/Compcov support (Bochs backend), and 6 instances running on the KVM backend. The experiment was repeated 5 times each one was running for 6 hours on a PC with Ubuntu, and Intel I5 processor (don't remember the exact model).

Coverage mean:

coverage

Execs/sec:

execs-sec

Corpus size:

corpus-size

The error bands here show +-1 std from the mean.

The conclusion I get from this evaluation is that it's not possible to say whether the LAF/Compcov mode really helps to fuzz Rizin, however it might show drastically better results on other targets.

Changes summary:

  • Added LAF/Compcov mode for the WTF (options: --laf, --compcov, --laf-allowed-ranges)
  • Added some basics scripts to run the experiments
  • Fixes for the gen_coverage_* scripts
  • Added basic logging functionality for the master instance

@0vercl0k
Copy link
Owner

Damn, this is looking awesome 😳🔥Thank you for sending this in!

I am currently traveling so it'll take me more time than usual to review this, bear with me 🙏

Cheers

LCID Locale, DWORD dwCmpFlags, PCNZWCH lpString1, int cchCount1,
PCNZWCH lpString2, int cchCount) = CompareStringW;
if (compare_string_w_ptr(LOCALE_USER_DEFAULT, 0, str5, sizeof(str5) / 2 - 1,
(const wchar_t *)buffer,

Check failure

Code scanning / CodeQL

Cast from char* to wchar_t* High

Conversion from const char * to const __wchar_t *. Use of invalid string can lead to undefined behavior.
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