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

Allow unspecified bits when deserializing the API's bitflags #3229

Merged
merged 4 commits into from
Nov 26, 2022

Conversation

nical
Copy link
Contributor

@nical nical commented Nov 23, 2022

Checklist

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

Connections

https://bugzilla.mozilla.org/show_bug.cgi?id=1771246 and a host of similar fuzz bugs where web content serves us unspecified bits in some of the API's bitflags.

Description

The bitflags_serde_shim crate treats unspecified bits as errors during deserialization. To make the browser integration easier, we want the unsepcified bits (which can be produced by web content) to turn into validation errors instead of panics during deserialization.

Thankfully the bitflags_serde_shim crate is quite trivial, so this PR inlines the macro with the required modification to not check the bits. In addition, bitflags_serde_shim feature is removed, the Serialize and Deserialize implementations are always the same and only their presence depend on the trace and replay feature flags.

Testing

A test for invalid buffer usage bits in create_buffer.

@nical
Copy link
Contributor Author

nical commented Nov 23, 2022

  • I'll follow this up with extra checks in wgpu-core.

@codecov-commenter
Copy link

Codecov Report

Merging #3229 (80991de) into master (04d12ba) will increase coverage by 0.96%.
The diff coverage is 63.66%.

@@            Coverage Diff             @@
##           master    #3229      +/-   ##
==========================================
+ Coverage   64.70%   65.67%   +0.96%     
==========================================
  Files          81       63      -18     
  Lines       38819    34310    -4509     
==========================================
- Hits        25118    22532    -2586     
+ Misses      13701    11778    -1923     
Impacted Files Coverage Δ
player/src/lib.rs 53.31% <ø> (ø)
wgpu-core/src/id.rs 81.25% <0.00%> (-2.63%) ⬇️
wgpu-core/src/lib.rs 96.55% <ø> (ø)
wgpu-core/src/present.rs 0.00% <0.00%> (ø)
wgpu-core/src/resource.rs 25.13% <ø> (ø)
wgpu-hal/src/empty.rs 0.00% <ø> (ø)
wgpu-hal/src/lib.rs 23.30% <ø> (-2.92%) ⬇️
wgpu/src/backend/direct.rs 55.16% <0.00%> (+0.05%) ⬆️
wgpu/src/lib.rs 50.44% <0.00%> (-2.38%) ⬇️
wgpu-hal/src/auxil/renderdoc.rs 40.50% <17.64%> (-3.40%) ⬇️
... and 55 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@nical nical force-pushed the bitflags-serde branch 3 times, most recently from d5e77b0 to 0ff92a6 Compare November 23, 2022 14:14
wgpu-core/src/binding_model.rs Show resolved Hide resolved
wgpu-types/src/lib.rs Show resolved Hide resolved
wgpu-types/src/lib.rs Outdated Show resolved Hide resolved
@cwfitzgerald
Copy link
Member

Got some merge conflicts

The bitflags_serde_shim treats unspecified bits as errors during deserialization. To make the browser integration easier, we want the unsepcified bits (which can be produced by web content) to turn into validation errors instead of panics during deserialization.

Thankfully the bitflags_serde_shim crate is quite trivial, so this PR inlines the macro with the required modification to not check the bits. In addition, bitflags_serde_shim feature is removed, the Serialize and Deserialize implementations are aways the same and only their presence depend on the trace and replay feature flags.
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.

3 participants