]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-until: make sure we'll exit bind_remount_recursive_with_mountinfo() loop eventually
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Mar 2021 12:47:17 +0000 (13:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Mar 2021 10:39:37 +0000 (11:39 +0100)
Just some robustness given that /proc/self/mountinfo was previously
broken in the kernel.

src/shared/mount-util.c

index 53516c671b1d6b2fcf6b8b7d0dce67f0402d2835..b9f46784db660b7956370cbbef196e1e0b992b6f 100644 (file)
@@ -204,6 +204,7 @@ int bind_remount_recursive_with_mountinfo(
 
         _cleanup_set_free_free_ Set *done = NULL;
         _cleanup_free_ char *simplified = NULL;
+        unsigned n_tries = 0;
         int r;
 
         assert(prefix);
@@ -239,6 +240,9 @@ int bind_remount_recursive_with_mountinfo(
                 char *x;
                 unsigned long orig_flags;
 
+                if (n_tries++ >= 32) /* Let's not retry this loop forever */
+                        return -EBUSY;
+
                 todo = set_new(&path_hash_ops);
                 if (!todo)
                         return -ENOMEM;