|
44 | 44 | //! Like boxes, `OwnedFd` values conceptually own the resource they point to,
|
45 | 45 | //! and free (close) it when they are dropped.
|
46 | 46 | //!
|
| 47 | +//! ## What about `/proc/self/mem` and similar OS features? |
| 48 | +//! |
| 49 | +//! Some platforms have a feature known as `/proc/self/mem`, which is a |
| 50 | +//! filesystem path that can be opened, producing a file descriptor that, when |
| 51 | +//! read from or written to, reads and writes the process's memory. These reads |
| 52 | +//! and writes happen outside the control of the Rust compiler, so they do not |
| 53 | +//! uphold Rust's memory safety guarantees. |
| 54 | +//! |
| 55 | +//! Does this mean that all APIs that might allow `/proc/self/mem` to be opened |
| 56 | +//! and read from or written to must be `unsafe`? No. Rust's safety guarantees |
| 57 | +//! only cover what the program itself can do, and not what entities outside |
| 58 | +//! the program can do to it. `/proc/self/mem` is considered to be such an |
| 59 | +//! external entity, along with debugggers and people with physical access to |
| 60 | +//! the hardware. This is true even in cases where the program is controling |
| 61 | +//! the external entity. |
| 62 | +//! |
| 63 | +//! If you desire to comprehensively prevent programs from reaching out and |
| 64 | +//! causing external entities to reach back in and violate memory safety, it's |
| 65 | +//! necessary to use *sandboxing*, which is outside the scope of `std`. |
| 66 | +//! |
47 | 67 | //! [`BorrowedFd<'a>`]: crate::os::unix::io::BorrowedFd
|
48 | 68 |
|
49 | 69 | #![stable(feature = "rust1", since = "1.0.0")]
|
|
0 commit comments