Blame SOURCES/autofs-5.1.8-fix-kernel-mount-status-notification.patch

6c38fb
autofs-5.1.8 - fix kernel mount status notification
6c38fb
6c38fb
From: Ian Kent <raven@themaw.net>
6c38fb
6c38fb
The status return for attempted mount notification is not done
6c38fb
correctly in some cases leading to a status being sent to the
6c38fb
kernel multiple times or the send causing an error.
6c38fb
6c38fb
We must send a status to the kernel but it needs to be the correct
6c38fb
one. It definitely shouldn't be sent twice for the same mount attempt
6c38fb
and shouldn't be failing.
6c38fb
6c38fb
Signed-off-by: Ian Kent <raven@themaw.net>
6c38fb
---
6c38fb
 CHANGELOG         |    1 +
6c38fb
 daemon/direct.c   |   19 +++++++++++--------
6c38fb
 daemon/indirect.c |   19 +++++++++++--------
6c38fb
 3 files changed, 23 insertions(+), 16 deletions(-)
6c38fb
6c38fb
--- autofs-5.1.4.orig/CHANGELOG
6c38fb
+++ autofs-5.1.4/CHANGELOG
6c38fb
@@ -78,6 +78,7 @@
6c38fb
 - fix empty mounts list return from unlink_mount_tree().
6c38fb
 - fix nonstrict offset mount fail handling.
6c38fb
 - remove intr hosts map mount option.
6c38fb
+- fix kernel mount status notification.
6c38fb
 
6c38fb
 xx/xx/2018 autofs-5.1.5
6c38fb
 - fix flag file permission.
6c38fb
--- autofs-5.1.4.orig/daemon/direct.c
6c38fb
+++ autofs-5.1.4/daemon/direct.c
6c38fb
@@ -1143,12 +1143,18 @@ int handle_packet_expire_direct(struct a
6c38fb
 	return 0;
6c38fb
 }
6c38fb
 
6c38fb
-static void mount_send_fail(void *arg)
6c38fb
+static void mount_send_status(void *arg)
6c38fb
 {
6c38fb
 	struct ioctl_ops *ops = get_ioctl_ops();
6c38fb
 	struct pending_args *mt = arg;
6c38fb
 	struct autofs_point *ap = mt->ap;
6c38fb
-	ops->send_fail(ap->logopt, mt->ioctlfd, mt->wait_queue_token, -ENOENT);
6c38fb
+
6c38fb
+	if (mt->status)
6c38fb
+		ops->send_fail(ap->logopt, mt->ioctlfd,
6c38fb
+			       mt->wait_queue_token, mt->status);
6c38fb
+	else
6c38fb
+		ops->send_ready(ap->logopt,
6c38fb
+				mt->ioctlfd, mt->wait_queue_token);
6c38fb
 	ops->close(ap->logopt, mt->ioctlfd);
6c38fb
 }
6c38fb
 
6c38fb
@@ -1177,7 +1183,8 @@ static void *do_mount_direct(void *arg)
6c38fb
 
6c38fb
 	pending_mutex_unlock(args);
6c38fb
 
6c38fb
-	pthread_cleanup_push(mount_send_fail, &mt;;
6c38fb
+	mt.status = 0;
6c38fb
+	pthread_cleanup_push(mount_send_status, &mt;;
6c38fb
 
6c38fb
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
6c38fb
 
6c38fb
@@ -1191,9 +1198,7 @@ static void *do_mount_direct(void *arg)
6c38fb
 	if (status == -1) {
6c38fb
 		error(ap->logopt,
6c38fb
 		      "can't stat direct mount trigger %s", mt.name);
6c38fb
-		ops->send_fail(ap->logopt,
6c38fb
-			       mt.ioctlfd, mt.wait_queue_token, -ENOENT);
6c38fb
-		ops->close(ap->logopt, mt.ioctlfd);
6c38fb
+		mt.status = -ENOENT;
6c38fb
 		pthread_setcancelstate(state, NULL);
6c38fb
 		pthread_exit(NULL);
6c38fb
 	}
6c38fb
@@ -1203,8 +1208,6 @@ static void *do_mount_direct(void *arg)
6c38fb
 		error(ap->logopt,
6c38fb
 		     "direct trigger not valid or already mounted %s",
6c38fb
 		     mt.name);
6c38fb
-		ops->send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token);
6c38fb
-		ops->close(ap->logopt, mt.ioctlfd);
6c38fb
 		pthread_setcancelstate(state, NULL);
6c38fb
 		pthread_exit(NULL);
6c38fb
 	}
6c38fb
--- autofs-5.1.4.orig/daemon/indirect.c
6c38fb
+++ autofs-5.1.4/daemon/indirect.c
6c38fb
@@ -674,13 +674,18 @@ int handle_packet_expire_indirect(struct
6c38fb
 	return 0;
6c38fb
 }
6c38fb
 
6c38fb
-static void mount_send_fail(void *arg)
6c38fb
+static void mount_send_status(void *arg)
6c38fb
 {
6c38fb
 	struct ioctl_ops *ops = get_ioctl_ops();
6c38fb
 	struct pending_args *mt = arg;
6c38fb
 	struct autofs_point *ap = mt->ap;
6c38fb
-	ops->send_fail(ap->logopt,
6c38fb
-		       ap->ioctlfd, mt->wait_queue_token, -ENOENT);
6c38fb
+
6c38fb
+	if (mt->status)
6c38fb
+		ops->send_fail(ap->logopt, ap->ioctlfd,
6c38fb
+			       mt->wait_queue_token, mt->status);
6c38fb
+	else
6c38fb
+		ops->send_ready(ap->logopt,
6c38fb
+				ap->ioctlfd, mt->wait_queue_token);
6c38fb
 }
6c38fb
 
6c38fb
 static void *do_mount_indirect(void *arg)
6c38fb
@@ -709,7 +714,8 @@ static void *do_mount_indirect(void *arg
6c38fb
 
6c38fb
 	pending_mutex_unlock(args);
6c38fb
 
6c38fb
-	pthread_cleanup_push(mount_send_fail, &mt;;
6c38fb
+	mt.status = 0;
6c38fb
+	pthread_cleanup_push(mount_send_status, &mt;;
6c38fb
 
6c38fb
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
6c38fb
 
6c38fb
@@ -722,9 +728,7 @@ static void *do_mount_indirect(void *arg
6c38fb
 	len = ncat_path(buf, sizeof(buf), ap->path, mt.name, mt.len);
6c38fb
 	if (!len) {
6c38fb
 		crit(ap->logopt, "path to be mounted is to long");
6c38fb
-		ops->send_fail(ap->logopt,
6c38fb
-			       ap->ioctlfd, mt.wait_queue_token,
6c38fb
-			      -ENAMETOOLONG);
6c38fb
+		mt.status = -ENAMETOOLONG;
6c38fb
 		pthread_setcancelstate(state, NULL);
6c38fb
 		pthread_exit(NULL);
6c38fb
 	}
6c38fb
@@ -733,7 +737,6 @@ static void *do_mount_indirect(void *arg
6c38fb
 	if (status != -1 && !(S_ISDIR(st.st_mode) && st.st_dev == mt.dev)) {
6c38fb
 		error(ap->logopt,
6c38fb
 		      "indirect trigger not valid or already mounted %s", buf);
6c38fb
-		ops->send_ready(ap->logopt, ap->ioctlfd, mt.wait_queue_token);
6c38fb
 		pthread_setcancelstate(state, NULL);
6c38fb
 		pthread_exit(NULL);
6c38fb
 	}