This is an archive of the discontinued LLVM Phabricator instance.

[Fuzzer] Afl driver changing iterations handling
ClosedPublic

Authored by devnexen on Jun 7 2018, 6:10 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

devnexen created this revision.Jun 7 2018, 6:10 AM
morehouse added inline comments.
lib/fuzzer/afl/afl_driver.cpp
309 ↗(On Diff #150310)

Maybe next_char would be a more descriptive name here.

314 ↗(On Diff #150310)

Would it make more sense to just exit if iterations is invalid?

315 ↗(On Diff #150310)

Since the if-block returns, else is unnecessary here.

316 ↗(On Diff #150310)

Please use static_cast here.

devnexen added inline comments.Jun 7 2018, 9:10 AM
lib/fuzzer/afl/afl_driver.cpp
316 ↗(On Diff #150310)

I usually prefer indeed but was not sure if you prefered C's cast style. Ok will address all points.

devnexen updated this revision to Diff 150349.Jun 7 2018, 9:18 AM
kcc added a comment.Jun 7 2018, 2:39 PM

is this testable (somewhere in test/fuzzer/afl-driver*)?

devnexen updated this revision to Diff 150414.Jun 7 2018, 3:15 PM

To avoid breaking tests, not exiting directly but keeping the default to 1000.

kcc added inline comments.Jun 7 2018, 3:18 PM
test/fuzzer/afl-driver.test
31 ↗(On Diff #150414)

if you use "not" in the test command line you can have a test like that is expected to break

devnexen updated this revision to Diff 150422.Jun 7 2018, 3:42 PM
morehouse added inline comments.Jun 11 2018, 10:17 AM
test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

Why have you changed these two lines?

devnexen added inline comments.Jun 11 2018, 1:12 PM
test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

Most likely because of the exit call. Without this, the previous test passes.

morehouse added inline comments.Jun 11 2018, 1:38 PM
test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

If I understand the code correctly, this should cause N to default to 1000. So I don't think exit should be called.

devnexen added inline comments.Jun 11 2018, 2:04 PM
test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

If I change the signature of set_iterations to return a value and bring back the else if (argc == 2 && ...) as it was the test passes somehow.

morehouse added inline comments.Jun 11 2018, 4:12 PM
test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

Ah, I see. The driver doesn't support specifying N with the deprecated call style. Let's move the deprecation warning to before the call to set_iterations, and change the above test to check for the deprecation warning + the iterations invalid warning.

devnexen updated this revision to Diff 150889.Jun 11 2018, 9:31 PM
devnexen added inline comments.
test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

I changed it as asked and realised it indeed exited, i.e the second warning (i.e iterations invalid) displays the path of the file as argument making the conversion to number failing for sure.

morehouse accepted this revision.Jun 12 2018, 8:44 AM
This revision is now accepted and ready to land.Jun 12 2018, 8:44 AM
This revision was automatically updated to reflect the committed changes.

Reposting my comments here from https://reviews.llvm.org/D49141

I think this patch should be reverted.
It breaks afl_driver's command line interface by causing invocations such as ./fuzzer inputfile to fail.
I don't think this breakage was intentional since ./fuzzer inputfile1 inputfile2 still works and I don't think there is a reason to break this.
I've created a revert here: https://reviews.llvm.org/D49141

lib/fuzzer/afl/afl_driver.cpp
335 ↗(On Diff #150422)

I don't think (N = atoi(argv[1])) > 0) should have been removed.
It allowed a single file to be passed to afl_driver.

test/fuzzer/afl-driver.test
25 ↗(On Diff #150422)

I think changing this test was incorrect. The test verified that the command line interface worked a certain way.
Thus the test WAI if this patch causes it to fail.