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

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