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

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