From 2a2b212ea3fd8e8bbc4bd209593a943b44fd9aee Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 8 Mar 2022 16:26:10 -0500 Subject: [PATCH 1/2] remove_dir_all: use fallback implementation on Miri --- library/std/src/sys/unix/fs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 03684608f75a6..ef8a57bdd2e6e 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1480,14 +1480,14 @@ pub fn chroot(dir: &Path) -> io::Result<()> { pub use remove_dir_impl::remove_dir_all; -// Fallback for REDOX and ESP-IDF -#[cfg(any(target_os = "redox", target_os = "espidf"))] +// Fallback for REDOX and ESP-IDF (and Miri) +#[cfg(any(target_os = "redox", target_os = "espidf", miri))] mod remove_dir_impl { pub use crate::sys_common::fs::remove_dir_all; } // Modern implementation using openat(), unlinkat() and fdopendir() -#[cfg(not(any(target_os = "redox", target_os = "espidf")))] +#[cfg(not(any(target_os = "redox", target_os = "espidf", miri)))] mod remove_dir_impl { use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir}; use crate::ffi::CStr; From 28eb06bd98169c985f4951b6aaf6855d52ffd514 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 8 Mar 2022 20:09:44 -0500 Subject: [PATCH 2/2] docs --- library/std/src/fs.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0b65336a5a7da..d3e668ed9c756 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2049,9 +2049,10 @@ pub fn remove_dir>(path: P) -> io::Result<()> { /// /// [changes]: io#platform-specific-behavior /// -/// On macOS before version 10.10 and REDOX this function is not protected against time-of-check to -/// time-of-use (TOCTOU) race conditions, and should not be used in security-sensitive code on -/// those platforms. All other platforms are protected. +/// On macOS before version 10.10 and REDOX, as well as when running in Miri for any target, this +/// function is not protected against time-of-check to time-of-use (TOCTOU) race conditions, and +/// should not be used in security-sensitive code on those platforms. All other platforms are +/// protected. /// /// # Errors ///