@@ -2915,17 +2915,28 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
2915
2915
///
2916
2916
/// # Platform-specific behavior
2917
2917
///
2918
- /// This function currently corresponds to `openat`, `fdopendir`, `unlinkat` and `lstat` functions
2919
- /// on Unix (except for REDOX) and the `CreateFileW`, `GetFileInformationByHandleEx`,
2920
- /// `SetFileInformationByHandle`, and `NtCreateFile` functions on Windows. Note that, this
2921
- /// [may change in the future][changes].
2918
+ /// These implementation details [may change in the future][changes].
2919
+ ///
2920
+ /// - "Unix-like": By default, this function currently corresponds to
2921
+ /// `openat`, `fdopendir`, `unlinkat` and `lstat`
2922
+ /// on Unix-family platforms, except where noted otherwise.
2923
+ /// - "Windows": This function currently corresponds to `CreateFileW`,
2924
+ /// `GetFileInformationByHandleEx`, `SetFileInformationByHandle`, and `NtCreateFile`.
2925
+ ///
2926
+ /// ## Time-of-check to time-of-use (TOCTOU) race conditions
2927
+ /// On a few platforms there is no way to remove a directory's contents without following symlinks
2928
+ /// unless you perform a check and then operate on paths based on that directory.
2929
+ /// This allows concurrently-running code to replace the directory with a symlink after the check,
2930
+ /// causing a removal to instead operate on a path based on the symlink. This is a TOCTOU race.
2931
+ /// By default, `fs::remove_dir_all` protects against a symlink TOCTOU race on all platforms
2932
+ /// except the following. It should not be used in security-sensitive contexts on these platforms:
2933
+ /// - Miri: Even when emulating targets where the underlying implementation will protect against
2934
+ /// TOCTOU races, Miri will not do so.
2935
+ /// - Redox OS: This function does not protect against TOCTOU races, as Redox does not implement
2936
+ /// the required platform support to do so.
2922
2937
///
2923
2938
/// [changes]: io#platform-specific-behavior
2924
2939
///
2925
- /// On REDOX, as well as when running in Miri for any target, this function is not protected against
2926
- /// time-of-check to time-of-use (TOCTOU) race conditions, and should not be used in
2927
- /// security-sensitive code on those platforms. All other platforms are protected.
2928
- ///
2929
2940
/// # Errors
2930
2941
///
2931
2942
/// See [`fs::remove_file`] and [`fs::remove_dir`].
0 commit comments