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

Provenance for zero-sized accesses? #490

Closed
joshlf opened this issue Feb 13, 2024 · 2 comments
Closed

Provenance for zero-sized accesses? #490

joshlf opened this issue Feb 13, 2024 · 2 comments

Comments

@joshlf
Copy link

joshlf commented Feb 13, 2024

Is provenance required in order to perform zero-sized accesses? Following up on rust-lang/rust#116677 (comment), I understand that it is sound (e.g. per the ptr module docs) to perform a zero-sized load or store using a pointer derived from any non-zero integer literal. Since integers do not have provenance, this implies that zero-sized accesses do not require valid provenance. Is that correct?

@digama0
Copy link

digama0 commented Feb 14, 2024

I believe this is covered by the FCP on zero-sized accesses #472 (which was approved but IIRC still has some implementation work to avoid LLVM miscompilations). All zero-sized accesses are allowed, including those with invalid provenance or no provenance. The ptr module docs have an exception for provenance to deallocated memory, but hopefully this can be removed at some point.

@digama0 digama0 closed this as completed Feb 14, 2024
@RalfJung
Copy link
Member

RalfJung commented Feb 14, 2024

The status quo is that zero-sized accesses require either valid provenance or no provenance.

rust-lang/rust#117945 tracks changing this to allowing any provenance.

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

No branches or pull requests

3 participants