-
Notifications
You must be signed in to change notification settings - Fork 953
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
Validate texture copy ranges earlier to prevent integer overflow #3090
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nit that would have required time travel - lgtm
validate_texture_copy_range has a number of important checks on sizes that we want to make as early as possible to prevent integer overflows in other places such as transfer::extract_texture_selector which computes copy_texture.origin.z + copy_size.depth_or_array_layers (overflow found by fuzzers as always). The fix is to call validate_texture_copy_range earlier, in particular before extract_texture_selector. Unfortunately it led to more code churn than I would have liked. Thankfully it is mechanical and simple: Rather than getting the texture reference from Tracker::set_single, we grab it earlier (for validation) and pass it to set_single instead of the texture guard. As a bonus we are looking texture texture up less often than we used to.
b45f72e
to
4084d8a
Compare
Codecov Report
@@ Coverage Diff @@
## master #3090 +/- ##
===========================================
- Coverage 65.41% 47.14% -18.27%
===========================================
Files 82 82
Lines 39455 39436 -19
===========================================
- Hits 25809 18592 -7217
- Misses 13646 20844 +7198
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Checklist
cargo clippy
.Connections
https://bugzilla.mozilla.org/show_bug.cgi?id=1791806
Description
validate_texture_copy_range
has a number of important checks on sizes that we want to make as early as possible to prevent integer overflows in other places such astransfer::extract_texture_selector
which computescopy_texture.origin.z + copy_size.depth_or_array_layers
(overflow found by a fuzzer, as always).The fix is to call validate_texture_copy_range earlier, in particular before extract_texture_selector.
Unfortunately it led to more code churn than I would have liked. Thankfully it is mechanical and simple: Rather than getting the texture reference from
Tracker::set_single
, we grab it earlier (for validation) and pass it toset_single
instead of the texture guard.As a bonus we are looking texture texture up less often than we used to, and we do all of the validation before starting to transition some states which sounds safer to me.
Testing
I did actually add a test this time around!