Blame SOURCES/autofs-5.1.4-set-bind-mount-as-propagation-slave.patch

aea863
autofs-5.1.4 - set bind mount as propagation slave
aea863
aea863
From: Ian Kent <raven@themaw.net>
aea863
aea863
When using a multi-mount with mount targets that are on the
aea863
local machine and resulting bind mounts are made to a file
aea863
system that is mount propagation shared (such as the root
aea863
file system on systemd managed systems) the autofs offset
aea863
mount triggers made within the bind mount will be propagated
aea863
back to the target file system.
aea863
aea863
When this happens the target of the offset (the unwanted
aea863
propagated mount) is itself an autofs trigger mount and
aea863
accessing the path results in a deadlock.
aea863
aea863
In order for these multi-mounts to function properly in this
aea863
case bind mounts that contain mount triggers must be set to
aea863
propagation slave or private so the backward propagation
aea863
doesn't occur.
aea863
aea863
Signed-off-by: Ian Kent <raven@themaw.net>
aea863
---
aea863
 CHANGELOG            |    1 +
aea863
 modules/mount_bind.c |   16 +++++++++++++++-
aea863
 2 files changed, 16 insertions(+), 1 deletion(-)
aea863
aea863
--- autofs-5.1.4.orig/CHANGELOG
aea863
+++ autofs-5.1.4/CHANGELOG
aea863
@@ -30,6 +30,7 @@ xx/xx/2018 autofs-5.1.5
aea863
 - fix program usage message.
aea863
 - fix update_negative_cache() map source usage.
aea863
 - mark removed cache entry negative.
aea863
+- set bind mount as propagation slave.
aea863
 
aea863
 19/12/2017 autofs-5.1.4
aea863
 - fix spec file url.
aea863
--- autofs-5.1.4.orig/modules/mount_bind.c
aea863
+++ autofs-5.1.4/modules/mount_bind.c
aea863
@@ -20,6 +20,7 @@
aea863
 #include <sys/param.h>
aea863
 #include <sys/types.h>
aea863
 #include <sys/stat.h>
aea863
+#include <sys/mount.h>
aea863
 
aea863
 #define MODULE_MOUNT
aea863
 #include "automount.h"
aea863
@@ -183,8 +184,21 @@ int mount_mount(struct autofs_point *ap,
aea863
 			debug(ap->logopt,
aea863
 			      MODPREFIX "mounted %s type %s on %s",
aea863
 			      what, fstype, fullpath);
aea863
-			return 0;
aea863
 		}
aea863
+
aea863
+		/* The bind mount has succeeded but if the target
aea863
+		 * mount is propagation shared propagation of child
aea863
+		 * mounts (autofs offset mounts for example) back to
aea863
+		 * the target of the bind mount must be avoided or
aea863
+		 * autofs trigger mounts will deadlock.
aea863
+		 */
aea863
+		err = mount(NULL, fullpath, NULL, MS_SLAVE, NULL);
aea863
+		if (err)
aea863
+			warn(ap->logopt,
aea863
+			     "failed to set propagation type for %s",
aea863
+			     fullpath);
aea863
+
aea863
+		return 0;
aea863
 	} else {
aea863
 		char *cp;
aea863
 		char basepath[PATH_MAX];