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

fuzzing: Limit the total number of API calls generated #1265

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Mar 9, 2020

To avoid libfuzzer timeouts, limit the total number of API calls we generate in
the api_calls fuzz target. We were already limiting the number of exported
function calls we made, and this extends the limit to all API calls.

To avoid libfuzzer timeouts, limit the total number of API calls we generate in
the `api_calls` fuzz target. We were already limiting the number of exported
function calls we made, and this extends the limit to all API calls.
let max_export_calls = 100;
// Total limit on number of API calls we'll generate. This exists to
// avoid libFuzzer timeouts.
let max_calls = 100;

for _ in 0..input.arbitrary_len::<ApiCall>()? {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not too familiar with the Arbitrary trait, but is there perhaps a way that we can hook in here? Is there a way to indicate that we want at most a particular number of API calls?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have int_in_range but this draws from the front of the byte string, rather than the end, like lengths do. The mechanism that lengths use to get an integer in a range from the end of the byte string isn't a public API, unfortunately. (Reason lengths should be drawn from the end of the byte string: https://github.com/rust-fuzz/libfuzzer-sys/blob/0c450753/libfuzzer/utils/FuzzedDataProvider.h#L92-L97)

Overall, I don't think it really matters too much, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed rust-fuzz/arbitrary#36 for posterity

@alexcrichton alexcrichton merged commit 67bfeea into bytecodealliance:master Mar 10, 2020
@fitzgen fitzgen deleted the limit-all-api-calls branch March 10, 2020 16:33
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