From 670e8efd6083bfef6186d33fa3b7dc90810d14ca Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 24 Mar 2021 13:47:17 +0100 Subject: [PATCH] mount-until: make sure we'll exit bind_remount_recursive_with_mountinfo() loop eventually Just some robustness given that /proc/self/mountinfo was previously broken in the kernel. --- src/shared/mount-util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index 53516c671b..b9f46784db 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -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;