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

Map bounds check #2938

Merged
merged 2 commits into from
Aug 4, 2022
Merged

Map bounds check #2938

merged 2 commits into from
Aug 4, 2022

Conversation

nical
Copy link
Contributor

@nical nical commented Aug 3, 2022

Checklist

  • Run cargo clippy.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections

Fixes #2935.

Description

The range is not entirely bounds checked in buffer_map_async. It uses unsigned integers guaranteeing that the range can't underflow the buffer, and the range's end is also checked against the size of the buffer, but a user calling into wgpu_core directly (such as Firefox), could pass a negative range which is invalid and also would allow the start offset to be outside of the bounds of the buffer.

The fix is simply to validate that the range is not negative. Since the end of the range is already validated against the buffer size, it means the buffer start isn't allowed to overflow the buffer.

Testing

None.

@nical nical force-pushed the map_bounds_check branch 2 times, most recently from c9bd036 to 6308d5e Compare August 3, 2022 14:11
@jimblandy
Copy link
Member

The CI failures here are due to the macOS 10.15 deprecation. I've filed #2940 for that.

@jimblandy
Copy link
Member

... and it would be good to rebase this PR on that once it lands, so we can get a clean run before merging.

map_async already checks that the range's end is within the bounds of the buffer, so this also ensures the range start is within bounds.
@jimblandy jimblandy merged commit ef3b31c into gfx-rs:master Aug 4, 2022
@nical nical deleted the map_bounds_check branch August 4, 2022 09:16
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.

wgpu_core::Device::buffer_map_async doesn't bounds-check range
2 participants