aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-04-10 17:16:55 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-04-10 16:06:33 +0000
commit33b9e058838dbe993f943107bcdd0223e831bd84 (patch)
tree1e59a020dd3791e1b9f53fbd74bc8280c73b6f9e /executor/common_linux.h
parent5b968ccf1481a8bae7fce49cca01cf3597da4be8 (diff)
executor: cleanup mounts with MNT_FORCE
Starting from v6.9, we can no longer reuse a loop device while some filesystem is mounted on it. It conflicts with the MNT_DETACH approach we were previously using. Let's umount synchronously instead, but also with a MNT_FORCE flag to abort potentially long graceful cleanup operations. We don't need them for the filesystems mounted only for fuzzing purposes.
Diffstat (limited to 'executor/common_linux.h')
-rw-r--r--executor/common_linux.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index eea0fd2cf..e83bad6c0 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -4534,10 +4534,15 @@ static void remove_dir(const char* dir)
DIR* dp = 0;
retry:
#if SYZ_EXECUTOR || !SYZ_SANDBOX_ANDROID
+ // Starting from v6.9, it does no longer make sense to use MNT_DETACH, because
+ // a loop device may only be reused in RW mode if no mounted filesystem keeps a
+ // reference to it. So we have to umount them synchronously.
+ // MNT_FORCE should hopefully prevent hangs for filesystems that may require a complex cleanup.
+ const int umount_flags = MNT_FORCE | UMOUNT_NOFOLLOW;
#if SYZ_EXECUTOR
if (!flag_sandbox_android)
#endif
- while (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW) == 0) {
+ while (umount2(dir, umount_flags) == 0) {
debug("umount(%s)\n", dir);
}
#endif
@@ -4563,7 +4568,7 @@ retry:
#if SYZ_EXECUTOR
if (!flag_sandbox_android)
#endif
- while (umount2(filename, MNT_DETACH | UMOUNT_NOFOLLOW) == 0) {
+ while (umount2(filename, umount_flags) == 0) {
debug("umount(%s)\n", filename);
}
#endif
@@ -4601,7 +4606,7 @@ retry:
if (!flag_sandbox_android) {
#endif
debug("umount(%s)\n", filename);
- if (umount2(filename, MNT_DETACH | UMOUNT_NOFOLLOW))
+ if (umount2(filename, umount_flags))
exitf("umount(%s) failed", filename);
#if SYZ_EXECUTOR
}
@@ -4636,7 +4641,7 @@ retry:
if (!flag_sandbox_android) {
#endif
debug("umount(%s)\n", dir);
- if (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW))
+ if (umount2(dir, umount_flags))
exitf("umount(%s) failed", dir);
#if SYZ_EXECUTOR
}