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

#[derive(IntoBytes)] on unions should not consider #[repr(packed)] sufficient to guarantee layout #1757

Closed
joshlf opened this issue Sep 25, 2024 · 1 comment
Labels
blocking-next-release This issue should be resolved before we release on crates.io bug Something isn't working

Comments

@joshlf
Copy link
Member

joshlf commented Sep 25, 2024

This is a soundness hole. #[repr(packed)] is a modifier to other reprs, but does not on its own guarantee layout, and does not require Rust to promise not to perform niche-filling optimizations.

While we're here, we should audit other locations where we permit repr(packed) without repr(C).

@joshlf joshlf added bug Something isn't working blocking-next-release This issue should be resolved before we release on crates.io labels Sep 25, 2024
@joshlf
Copy link
Member Author

joshlf commented Sep 30, 2024

Update: we've decided this isn't a problem since we don't support unions with generics, and so we always emit a padding check. Since union fields are entire types (unlike enum variants, which can have sub-fields), our existing union padding check is sufficient.

@joshlf joshlf closed this as completed Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking-next-release This issue should be resolved before we release on crates.io bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant