From 6b4dbdbf47a73de688df06d50dada7ba80df9458 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 27 Jul 2021 16:58:38 -0700 Subject: [PATCH] Be more precise about `mmap` and undefined behavior. `mmap` doesn't *always* cause undefined behavior; it depends on the details of how you use it. --- library/std/src/os/unix/io/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/std/src/os/unix/io/mod.rs b/library/std/src/os/unix/io/mod.rs index 06f47cbb31f0..fd1394a0520d 100644 --- a/library/std/src/os/unix/io/mod.rs +++ b/library/std/src/os/unix/io/mod.rs @@ -32,9 +32,9 @@ //! other code using that file descriptor. //! This list doesn't include `mmap`, since `mmap` does do a proper borrow of //! its file descriptor argument. That said, `mmap` is unsafe for other -//! reasons: it operates on raw pointers, and it has undefined behavior if the -//! underlying storage is mutated. Mutations may come from other processes, or -//! from the same process if the API provides `BorrowedFd` access, since as +//! reasons: it operates on raw pointers, and it can have undefined behavior if +//! the underlying storage is mutated. Mutations may come from other processes, +//! or from the same process if the API provides `BorrowedFd` access, since as //! mentioned earlier, `BorrowedFd` values may be used in APIs which provide //! safe access to any system call. Consequently, code using `mmap` and //! presenting a safe API must take full responsibility for ensuring that safe