forked from google/zerocopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ptr] Fix soundness hole in "at least" invariants (google#909)
Previously, we spuriously implemented `at_least::Initialized` for the `Valid` invariant, which is unsound. This was introduced because, prior to the introduction of the `Initialized` invariant, all invariants were monotonic - when defined in the proper order, every invariant was at least as strict as all preceding invariants. Thus, the `define_system!` macro we use to define a system of invariants automatically emitted the appropriate impls based on this monotonicity assumption. `Initialized` broke this assumption, but we didn't update the macro to match. This commit changes the `define_system!` macro to require the caller to explicitly define the "at least" relation. It also adds a test to prevent regressions. As a consequence of making the "at least" relation explicit, we remove the `at_least::Initialized` trait, since this trait would have no non-trivial implementations.
- Loading branch information
1 parent
f26566c
commit 83ad934
Showing
1 changed file
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters