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 running AFL with no 'fuzzing' flag #398

Merged
merged 6 commits into from
Oct 9, 2023

Conversation

lrubasze
Copy link
Contributor

@lrubasze lrubasze commented Oct 6, 2023

This is to address issue #397

In order to prevent cargo-afl from setting fuzzing flag one needs to set AFL_NO_CFG_FUZZING environmental variable.
Eg.

 AFL_NO_CFG_FUZZING=1 cargo afl build 

@@ -310,7 +310,8 @@ where
-C target-cpu=native "
);

if cfg!(not(feature = "no_cfg_fuzzing")) {
let no_cfg_fuzzing = env::var("AFL_NO_CFG_FUZZING").unwrap_or_default();
if no_cfg_fuzzing.is_empty() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note from author:

Alternatively I was thinking also of adding else clause with:

  • removing AFL_NO_CFG_FUZZING here
  • setting config no_fuzzing

and not adding env to the Command in line 347.

It would be more elegant than this. But that no_fuzzing config could be somehow confusing.

Copy link

@smoelius1 smoelius1 Oct 7, 2023

Choose a reason for hiding this comment

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

So, essentially, cargo-afl would turn the environment variable into a config option?

I think I like that idea.

That way, afl/build.rs should not need to consider AFL_ environment variables at all (right?).

Apologies, I am traveling (hence, the funny account) and the earliest I will be able to merge anything will be Monday evening ET.

EDIT: Edited to say "AFL_ environment variables" instead of just "environment variables".

Choose a reason for hiding this comment

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

Also, let's please use just .is_ok() to check whether AFL_NO_CFG_FUZZING is enabled. That is the convention used for other environment variables, currently.

@vanhauser-thc
Copy link
Contributor

README.md Outdated
@@ -43,6 +43,9 @@ So if you run multiple AFL++ instances on your fuzzing target, you can disable C
This [document](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/fuzzing_in_depth.md)
will familiarize you with AFL++ features to help in running a successful fuzzing campaign.

By default, 'fuzzing' config is set when `cargo-afl` is used to build. If you want to prevent this, just set 'AFL_NO_CFG_FUZZING=1`
environmental variable, when building.

Choose a reason for hiding this comment

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

Thanks,, @lrubasze!

Just one nit. Could this please read something like the following?

set the environment variable AFL_NO_CFG_FUZZING to 1 when building.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My english really sucks 😄 Thanks for spotting this.

@smoelius
Copy link
Member

smoelius commented Oct 9, 2023

Thanks again, @lrubasze. 🙏

@smoelius smoelius merged commit f8bb469 into rust-fuzz:master Oct 9, 2023
10 checks passed
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.

None yet

4 participants