google / google/zerocopy

Tracking issue for ensuring `isValid` soundness

Open
#3,107 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
179
Avg merge
1d 19h
Merged PRs (30d)
29

Description

*See also: https://github.com/google/zerocopy/issues/3088*

Currently, `isValid` is only enforced whenever there is a Hermes annotation. Un-annotated functions can violate `isValid` invariants. Since we don't have [unsafe fields](https://github.com/rust-lang/rfcs/pull/3458), Rust doesn't prevent modifying a field in such a way that violates type-level invariants. In particular, these modifications don't require `unsafe`, which in turn means they don't require a safety comment, which in turn means they don't require a Hermes annotation.

Once unsafe fields are stabilized, we can just require them. In the meantime, here is a roadmap to closing the `isValid` soundness gap without unsafe fields:
- [x] Current state: `isValid` is not reliably enforced, so users must exercise care
- [ ] Require passing `--unsound-is-valid` to enable `isValid` annotations
- [ ] Permit *module*-level annotations without `--unsound-is-valid`
- At the module level, so long as fields are private, Hermes can see all code that can read/modify fields which carry safety invariants
- [ ] Support unsafe fields once it's fully implemented in Rust
- https://github.com/rust-lang/rust/issues/132922

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.