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

tests(s2n-quic-core): enable kani for stream try_fit function #1667

Merged
merged 3 commits into from
Mar 29, 2023

Conversation

camshaft
Copy link
Contributor

Description of changes:

This change enables a kani proof for the stream frame try_fit function.

Testing

Enabling this proof actually found a bug in the test harness that was overly strict on the fit function. Since this code is in a pretty hot path, we could return a more optimized result at the expense of brute-force computation of each possible length, but it would only save at most a byte or 2 (since our lengths are under 2^16 in practice). As such, I've updated the harness to include the logic to consider intentional unoptimal results.

What's super interesting is libFuzzer didn't catch this, even after running it for quite some time. On the other hand, kani returns a counter example quite quickly:

#[test]
fn try_fit_test_concrete() {
    model(VarInt::new(48).unwrap(), VarInt::new(128).unwrap(), VarInt::new(64).unwrap(), 69);
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft merged commit cbb1187 into main Mar 29, 2023
@camshaft camshaft deleted the camshaft/try-fit-stream-kani branch March 29, 2023 19:38
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