diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-20 14:56:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-20 14:56:40 +0200 |
| commit | ce1151c04c8aa529a81d124d41cc900c7da7d4ac (patch) | |
| tree | 03d0da8347e5f9b7db049d060b47a1f1564d8887 | |
| parent | 2807f28de550fb6074dc4fb2f3099865de01bc1e (diff) | |
| parent | 69594414bfac4d0ae10da65ccffad6ab4b0fa05a (diff) | |
| download | rust-ce1151c04c8aa529a81d124d41cc900c7da7d4ac.tar.gz rust-ce1151c04c8aa529a81d124d41cc900c7da7d4ac.zip | |
Rollup merge of #97837 - sunfishcode:sunfishcode/proc-self-mem, r=m-ou-se
Document Rust's stance on `/proc/self/mem` Add documentation to `std::os::unix::io` describing Rust's stance on `/proc/self/mem`, treating it as an external entity which is outside the scope of Rust's safety guarantees.
| -rw-r--r-- | library/std/src/os/unix/io/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/library/std/src/os/unix/io/mod.rs b/library/std/src/os/unix/io/mod.rs index 7556d3ad0b2..3ab5606f889 100644 --- a/library/std/src/os/unix/io/mod.rs +++ b/library/std/src/os/unix/io/mod.rs @@ -54,6 +54,25 @@ //! Like boxes, `OwnedFd` values conceptually own the resource they point to, //! and free (close) it when they are dropped. //! +//! ## `/proc/self/mem` and similar OS features +//! +//! Some platforms have special files, such as `/proc/self/mem`, which +//! provide read and write access to the process's memory. Such reads +//! and writes happen outside the control of the Rust compiler, so they do not +//! uphold Rust's memory safety guarantees. +//! +//! This does not mean that all APIs that might allow `/proc/self/mem` +//! to be opened and read from or written must be `unsafe`. Rust's safety guarantees +//! only cover what the program itself can do, and not what entities outside +//! the program can do to it. `/proc/self/mem` is considered to be such an +//! external entity, along with debugging interfaces, and people with physical access to +//! the hardware. This is true even in cases where the program is controlling +//! the external entity. +//! +//! If you desire to comprehensively prevent programs from reaching out and +//! causing external entities to reach back in and violate memory safety, it's +//! necessary to use *sandboxing*, which is outside the scope of `std`. +//! //! [`BorrowedFd<'a>`]: crate::os::unix::io::BorrowedFd #![stable(feature = "rust1", since = "1.0.0")] |
