Skip to content

Commit f40c10a

Browse files
jswrennjoshlf
andauthored
Document zerocopy's design ethos. (#405)
Co-authored-by: Joshua Liebow-Feeser <[email protected]>
1 parent 8bdcb2f commit f40c10a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,27 @@ for network parsing.
8686

8787
[simd-layout]: https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
8888

89+
## Security Ethos
90+
91+
Zerocopy is expressly designed for use in security-critical contexts. We
92+
strive to ensure that that zerocopy code is sound under Rust's current
93+
memory model, and *any future memory model*. We ensure this by:
94+
- **...not 'guessing' about Rust's semantics.**
95+
We annotate `unsafe` code with a precise rationale for its soundness that
96+
cites a relevant section of Rust's official documentation. When Rust's
97+
documented semantics are unclear, we work with the Rust Operational
98+
Semantics Team to clarify Rust's documentation.
99+
- **...rigorously testing our implementation.**
100+
We run tests using [Miri], ensuring that zerocopy is sound across a wide
101+
array of supported target platforms of varying endianness and pointer
102+
width, and across both current and experimental memory models of Rust.
103+
- **...formally proving the correctness of our implementation.**
104+
We apply formal verification tools like [Kani][kani] to prove zerocopy's
105+
correctness.
106+
107+
[Miri]: https://github.com/rust-lang/miri
108+
[Kani]: https://github.com/model-checking/kani
109+
89110
## Disclaimer
90111

91112
Disclaimer: Zerocopy is not an officially supported Google product.

src/lib.rs

+21
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,27 @@
8484
//! may be removed at any point in the future.
8585
//!
8686
//! [simd-layout]: https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
87+
//!
88+
//! # Security Ethos
89+
//!
90+
//! Zerocopy is expressly designed for use in security-critical contexts. We
91+
//! strive to ensure that that zerocopy code is sound under Rust's current
92+
//! memory model, and *any future memory model*. We ensure this by:
93+
//! - **...not 'guessing' about Rust's semantics.**
94+
//! We annotate `unsafe` code with a precise rationale for its soundness that
95+
//! cites a relevant section of Rust's official documentation. When Rust's
96+
//! documented semantics are unclear, we work with the Rust Operational
97+
//! Semantics Team to clarify Rust's documentation.
98+
//! - **...rigorously testing our implementation.**
99+
//! We run tests using [Miri], ensuring that zerocopy is sound across a wide
100+
//! array of supported target platforms of varying endianness and pointer
101+
//! width, and across both current and experimental memory models of Rust.
102+
//! - **...formally proving the correctness of our implementation.**
103+
//! We apply formal verification tools like [Kani][kani] to prove zerocopy's
104+
//! correctness.
105+
//!
106+
//! [Miri]: https://github.com/rust-lang/miri
107+
//! [Kani]: https://github.com/model-checking/kani
87108
88109
// Sometimes we want to use lints which were added after our MSRV.
89110
// `unknown_lints` is `warn` by default and we deny warnings in CI, so without

0 commit comments

Comments
 (0)