Blame SOURCES/autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch

4218b4
autofs-5.1.8 - fix handling of incorrect return from umount_ent()
4218b4
4218b4
From: Ian Kent <raven@themaw.net>
4218b4
4218b4
Commit 0210535df4b ("autofs-5.1.0 - gaurd against incorrect umount
4218b4
return") guards against umount_ent() returning a fail when the mount
4218b4
has actually been umounted.
4218b4
4218b4
But we also see umount_ent() return success when in fact the mount has
4218b4
not been umounted leading to incorrect handling of automounts.
4218b4
4218b4
So checking the return of umount_ent() isn't always giving the correct
4218b4
result in more than just one case, consequently we should ignore the
4218b4
result from the spawned umount(8) and check if the mount has in fact
4218b4
been umounted.
4218b4
4218b4
Signed-off-by: Ian Kent <raven@themaw.net>
4218b4
---
4218b4
 CHANGELOG          |    1 +
4218b4
 daemon/automount.c |    3 +--
4218b4
 lib/mounts.c       |   19 ++++++++++---------
4218b4
 3 files changed, 12 insertions(+), 11 deletions(-)
4218b4
4218b4
--- autofs-5.1.7.orig/CHANGELOG
4218b4
+++ autofs-5.1.7/CHANGELOG
4218b4
@@ -95,6 +95,7 @@
4218b4
 - avoid calling pthread_getspecific() with NULL key_thread_attempt_id.
4218b4
 - fix sysconf(3) return handling.
4218b4
 - remove nonstrict parameter from tree_mapent_umount_offsets().
4218b4
+- fix handling of incorrect return from umount_ent().
4218b4
 
4218b4
 25/01/2021 autofs-5.1.7
4218b4
 - make bind mounts propagation slave by default.
4218b4
--- autofs-5.1.7.orig/daemon/automount.c
4218b4
+++ autofs-5.1.7/daemon/automount.c
4218b4
@@ -605,8 +605,7 @@ static int umount_subtree_mounts(struct
4218b4
 		struct mnt_list *mnt;
4218b4
 
4218b4
 		debug(ap->logopt, "unmounting dir = %s", path);
4218b4
-		if (umount_ent(ap, path) &&
4218b4
-		    is_mounted(path, MNTS_REAL)) {
4218b4
+		if (umount_ent(ap, path)) {
4218b4
 			warn(ap->logopt, "could not umount dir %s", path);
4218b4
 			left++;
4218b4
 			goto done;
4218b4
--- autofs-5.1.7.orig/lib/mounts.c
4218b4
+++ autofs-5.1.7/lib/mounts.c
4218b4
@@ -1869,8 +1869,7 @@ static int tree_mapent_umount_offset(str
4218b4
 	 */
4218b4
 	if (oe->ioctlfd != -1 ||
4218b4
 	    is_mounted(oe->key, MNTS_REAL)) {
4218b4
-		if (umount_ent(ap, oe->key) &&
4218b4
-		    is_mounted(oe->key, MNTS_REAL)) {
4218b4
+		if (umount_ent(ap, oe->key)) {
4218b4
 			debug(ap->logopt,
4218b4
 			      "offset %s has active mount, invalidate",
4218b4
 			      oe->key);
4218b4
@@ -2010,8 +2009,7 @@ int tree_mapent_umount_offsets(struct ma
4218b4
 		 */
4218b4
 		if (is_mounted(mp, MNTS_REAL)) {
4218b4
 			info(ap->logopt, "unmounting dir = %s", mp);
4218b4
-			if (umount_ent(ap, mp) &&
4218b4
-			    is_mounted(mp, MNTS_REAL)) {
4218b4
+			if (umount_ent(ap, mp)) {
4218b4
 				if (!tree_mapent_mount_offsets(oe, 1))
4218b4
 					warn(ap->logopt,
4218b4
 					     "failed to remount offset triggers");
4218b4
@@ -2982,6 +2980,7 @@ void set_direct_mount_tree_catatonic(str
4218b4
 
4218b4
 int umount_ent(struct autofs_point *ap, const char *path)
4218b4
 {
4218b4
+	unsigned int mounted;
4218b4
 	int rv;
4218b4
 
4218b4
 	if (ap->state != ST_SHUTDOWN_FORCE)
4218b4
@@ -2993,6 +2992,8 @@ int umount_ent(struct autofs_point *ap,
4218b4
 		rv = spawn_umount(ap->logopt, "-l", path, NULL);
4218b4
 	}
4218b4
 
4218b4
+	mounted = is_mounted(path, MNTS_REAL);
4218b4
+
4218b4
 	if (rv && (ap->state == ST_SHUTDOWN_FORCE || ap->state == ST_SHUTDOWN)) {
4218b4
 		/*
4218b4
 		 * Verify that we actually unmounted the thing.  This is a
4218b4
@@ -3004,20 +3005,20 @@ int umount_ent(struct autofs_point *ap,
4218b4
 		 * so that we do not try to call rmdir_path on the
4218b4
 		 * directory.
4218b4
 		 */
4218b4
-		if (is_mounted(path, MNTS_REAL)) {
4218b4
+		if (mounted) {
4218b4
 			crit(ap->logopt,
4218b4
 			     "the umount binary reported that %s was "
4218b4
 			     "unmounted, but there is still something "
4218b4
 			     "mounted on this path.", path);
4218b4
-			rv = -1;
4218b4
+			mounted = -1;
4218b4
 		}
4218b4
 	}
4218b4
 
4218b4
-	/* On success, check for mounted mount and remove it if found */
4218b4
-	if (!rv)
4218b4
+	/* If mount is gone remove it from mounted mounts list. */
4218b4
+	if (!mounted)
4218b4
 		mnts_remove_mount(path, MNTS_MOUNTED);
4218b4
 
4218b4
-	return rv;
4218b4
+	return mounted;
4218b4
 }
4218b4
 
4218b4
 int umount_amd_ext_mount(struct autofs_point *ap, const char *path)