systemd/backport-mount-until-make-sure-we-ll-exit-bind_remount_recurs.patch
2023-12-18 15:30:01 +08:00

43 lines
1.4 KiB
Diff

From 0ae299022a0d7a05e6bc044f5e54f534f6cc6dbf Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
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.
(cherry picked from commit 670e8efd6083bfef6186d33fa3b7dc90810d14ca)
Conflict:different code contexts, manual synchronization path
Reference:https://github.com/systemd/systemd-stable/commit/0ae299022a0d7a05e6bc044f5e54f534f6cc6dbf
---
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 e5fc3d0..520894a 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -119,6 +119,7 @@ int bind_remount_recursive_with_mountinfo(
_cleanup_set_free_free_ Set *done = NULL;
_cleanup_free_ char *cleaned = NULL;
+ unsigned n_tries = 0;
int r;
assert(proc_self_mountinfo);
@@ -152,6 +153,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;
--
2.27.0