From 889e861e9d1043a3469eab76c733b64e2bd4ec14 Mon Sep 17 00:00:00 2001 From: Jonathan Krebs Date: Mon, 22 Apr 2024 23:31:55 +0200 Subject: [PATCH] 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 --- test/mount/test_mount.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/mount/test_mount.rs b/test/mount/test_mount.rs index a4f0903dba..65004465d5 100644 --- a/test/mount/test_mount.rs +++ b/test/mount/test_mount.rs @@ -53,6 +53,8 @@ fn test_mount_tmpfs_without_flags_allows_rwx() { .unwrap_or_else(|e| panic!("read failed: {e}")); assert_eq!(buf, SCRIPT_CONTENTS); + // while forking and unmounting prevent other child processes + let _m = FORK_MTX.lock(); // Verify execute. assert_eq!( EXPECTED_STATUS, @@ -89,6 +91,8 @@ fn test_mount_rdonly_disallows_write() { .unwrap() ); + // wait for child processes to prevent EBUSY + let _m = FORK_MTX.lock(); umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}")); } @@ -129,6 +133,8 @@ fn test_mount_noexec_disallows_exec() { &test_path ); + // while forking and unmounting prevent other child processes + let _m = FORK_MTX.lock(); // EACCES: Permission denied assert_eq!( EACCES, @@ -168,6 +174,8 @@ fn test_mount_bind() { .and_then(|mut f| f.write(SCRIPT_CONTENTS)) .unwrap_or_else(|e| panic!("write failed: {e}")); + // wait for child processes to prevent EBUSY + let _m = FORK_MTX.lock(); umount(mount_point.path()) .unwrap_or_else(|e| panic!("umount failed: {e}")); }