Blame SOURCES/autofs-5.1.0-dont-allocate-dev_ctl_ops-too-early.patch

306fa1
autofs-5.1.0 - dont allocate dev_ctl_ops too early
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
If the standard io file descriptors have been closed by the cloning
306fa1
process the file handle for autofs device control can correspond to
306fa1
a descriptor number of one of the standard io descriptors which will
306fa1
be closed when the process is daemonized.
306fa1
306fa1
Avoid this by closing the device control descriptor opened when
306fa1
performing sanity checks at startup so that it can be opened
306fa1
on a higher numbered file descriptor after the process has switched
306fa1
to daemon mode.
306fa1
---
306fa1
 CHANGELOG    |    1 +
306fa1
 lib/mounts.c |   14 +++++++++++++-
306fa1
 2 files changed, 14 insertions(+), 1 deletion(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -127,6 +127,7 @@
306fa1
 - allow empty value for some map options.
306fa1
 - allow empty value in macro selectors.
306fa1
 - add serialization to sasl init.
306fa1
+- dont allocate dev_ctl_ops too early.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/lib/mounts.c
306fa1
+++ autofs-5.0.7/lib/mounts.c
306fa1
@@ -90,7 +90,7 @@ unsigned int linux_version_code(void)
306fa1
 
306fa1
 unsigned int query_kproto_ver(void)
306fa1
 {
306fa1
-	struct ioctl_ops *ops = get_ioctl_ops();
306fa1
+	struct ioctl_ops *ops;
306fa1
 	char dir[] = "/tmp/autoXXXXXX", *t_dir;
306fa1
 	char options[MAX_OPTIONS_LEN + 1];
306fa1
 	pid_t pgrp = getpgrp();
306fa1
@@ -131,10 +131,19 @@ unsigned int query_kproto_ver(void)
306fa1
 		return 0;
306fa1
 	}
306fa1
 
306fa1
+	ops = get_ioctl_ops();
306fa1
+	if (!ops) {
306fa1
+		umount(t_dir);
306fa1
+		close(pipefd[0]);
306fa1
+		rmdir(t_dir);
306fa1
+		return 0;
306fa1
+	}
306fa1
+
306fa1
 	ops->open(LOGOPT_NONE, &ioctlfd, st.st_dev, t_dir);
306fa1
 	if (ioctlfd == -1) {
306fa1
 		umount(t_dir);
306fa1
 		close(pipefd[0]);
306fa1
+		close_ioctl_ctl();
306fa1
 		rmdir(t_dir);
306fa1
 		return 0;
306fa1
 	}
306fa1
@@ -146,6 +155,7 @@ unsigned int query_kproto_ver(void)
306fa1
 		ops->close(LOGOPT_NONE, ioctlfd);
306fa1
 		umount(t_dir);
306fa1
 		close(pipefd[0]);
306fa1
+		close_ioctl_ctl();
306fa1
 		rmdir(t_dir);
306fa1
 		return 0;
306fa1
 	}
306fa1
@@ -155,6 +165,7 @@ unsigned int query_kproto_ver(void)
306fa1
 		ops->close(LOGOPT_NONE, ioctlfd);
306fa1
 		umount(t_dir);
306fa1
 		close(pipefd[0]);
306fa1
+		close_ioctl_ctl();
306fa1
 		rmdir(t_dir);
306fa1
 		return 0;
306fa1
 	}
306fa1
@@ -162,6 +173,7 @@ unsigned int query_kproto_ver(void)
306fa1
 	ops->close(LOGOPT_NONE, ioctlfd);
306fa1
 	umount(t_dir);
306fa1
 	close(pipefd[0]);
306fa1
+	close_ioctl_ctl();
306fa1
 	rmdir(t_dir);
306fa1
 
306fa1
 	return 1;