Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 889e861

Browse files
committedApr 22, 2024
mount tests: take FORK_MTX when forking or unmounting
unmounting can fail if a child process inherited a file a file descriptor we opened in temporary mount point Should fix #2369
1 parent f129095 commit 889e861

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎test/mount/test_mount.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ fn test_mount_tmpfs_without_flags_allows_rwx() {
5353
.unwrap_or_else(|e| panic!("read failed: {e}"));
5454
assert_eq!(buf, SCRIPT_CONTENTS);
5555

56+
// while forking and unmounting prevent other child processes
57+
let _m = FORK_MTX.lock();
5658
// Verify execute.
5759
assert_eq!(
5860
EXPECTED_STATUS,
@@ -89,6 +91,8 @@ fn test_mount_rdonly_disallows_write() {
8991
.unwrap()
9092
);
9193

94+
// wait for child processes to prevent EBUSY
95+
let _m = FORK_MTX.lock();
9296
umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}"));
9397
}
9498

@@ -129,6 +133,8 @@ fn test_mount_noexec_disallows_exec() {
129133
&test_path
130134
);
131135

136+
// while forking and unmounting prevent other child processes
137+
let _m = FORK_MTX.lock();
132138
// EACCES: Permission denied
133139
assert_eq!(
134140
EACCES,
@@ -168,6 +174,8 @@ fn test_mount_bind() {
168174
.and_then(|mut f| f.write(SCRIPT_CONTENTS))
169175
.unwrap_or_else(|e| panic!("write failed: {e}"));
170176

177+
// wait for child processes to prevent EBUSY
178+
let _m = FORK_MTX.lock();
171179
umount(mount_point.path())
172180
.unwrap_or_else(|e| panic!("umount failed: {e}"));
173181
}

0 commit comments

Comments
 (0)
Please sign in to comment.