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

Fix unsoundness in impl_for_transparent_wrapper! #1585

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Aug 9, 2024

Previously, impl_for_transparent_wrapper! permitted the following unsound code to compile:

impl_for_transparent_wrapper!(FromBytes for AtomicBool);

impl_for_transparent_wrapper! attempted to ensure that AtomicBool's inner type implemented FromBytes, but failed to properly enforce this bound (it should have failed thanks to bool: !FromBytes).

This commit simplifies impl_for_transparent_wrapper! and fixes this soundness hole.

This fix is adapted from @josephlr's similar fix in #1091. Credit to @josephlr for discovering this soundness hole.

Previously, `impl_for_transparent_wrapper!` permitted the following
unsound code to compile:

  impl_for_transparent_wrapper!(FromBytes for AtomicBool);

`impl_for_transparent_wrapper!` attempted to ensure that `AtomicBool`'s
inner type implemented `FromBytes`, but failed to properly enforce this
bound (it should have failed thanks to `bool: !FromBytes`).

This commit simplifies `impl_for_transparent_wrapper!` and fixes this
soundness hole.

This fix is adapted from @josephlr's similar fix in #1091. Credit to
@josephlr for discovering this soundness hole.

Co-authored-by: Joe Richey <[email protected]>
@joshlf joshlf force-pushed the impl-for-transparent-wrapper-soundness branch from 3cd1658 to f0a52b5 Compare August 9, 2024 20:55
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.70%. Comparing base (4c3165f) to head (f0a52b5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1585   +/-   ##
=======================================
  Coverage   87.70%   87.70%           
=======================================
  Files          15       15           
  Lines        5565     5565           
=======================================
  Hits         4881     4881           
  Misses        684      684           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshlf joshlf added this pull request to the merge queue Aug 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@joshlf joshlf added this pull request to the merge queue Aug 13, 2024
Merged via the queue into main with commit 418555a Aug 13, 2024
77 checks passed
@joshlf joshlf deleted the impl-for-transparent-wrapper-soundness branch August 13, 2024 00: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.

3 participants