Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706012

[PATCH 3/3] autofs - make dev ioctl version and ismountpoint user accessible

From Ian Kent <raven@themaw.net>
Newsgroups linux.kernel
Subject [PATCH 3/3] autofs - make dev ioctl version and ismountpoint user accessible
Date 2017-08-08 06:40 +0200
Message-ID <uc4tb-2HR-11@gated-at.bofh.it> (permalink)
References <uc4tb-2HR-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Some of the autofs miscellaneous device ioctls need to be accessable to
user space applications without CAP_SYS_ADMIN to get information about
autofs mounts.

Signed-off-by: Ian Kent <raven@themaw.net>
Cc: Colin Walters <walters@redhat.com>
Cc: Ondrej Holy <oholy@redhat.com>
---
 fs/autofs4/dev-ioctl.c              |   12 ++++++++----
 include/uapi/linux/auto_dev-ioctl.h |    2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 218a4ecc75cc..ea8b3a1cddd2 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -628,10 +628,6 @@ static int _autofs_dev_ioctl(unsigned int command,
 	ioctl_fn fn = NULL;
 	int err = 0;
 
-	/* only root can play with this */
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
 	cmd_first = _IOC_NR(AUTOFS_DEV_IOCTL_IOC_FIRST);
 	cmd = _IOC_NR(command);
 
@@ -640,6 +636,14 @@ static int _autofs_dev_ioctl(unsigned int command,
 		return -ENOTTY;
 	}
 
+	/* Only root can use ioctls other than AUTOFS_DEV_IOCTL_VERSION_CMD
+	 * and AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD
+	 */
+	if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD &&
+	    cmd != AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD &&
+	    !capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
 	/* Copy the parameters into kernel space. */
 	param = copy_dev_ioctl(user);
 	if (IS_ERR(param))
diff --git a/include/uapi/linux/auto_dev-ioctl.h b/include/uapi/linux/auto_dev-ioctl.h
index 744b3d060968..5558db8e6646 100644
--- a/include/uapi/linux/auto_dev-ioctl.h
+++ b/include/uapi/linux/auto_dev-ioctl.h
@@ -16,7 +16,7 @@
 #define AUTOFS_DEVICE_NAME		"autofs"
 
 #define AUTOFS_DEV_IOCTL_VERSION_MAJOR	1
-#define AUTOFS_DEV_IOCTL_VERSION_MINOR	0
+#define AUTOFS_DEV_IOCTL_VERSION_MINOR	1
 
 #define AUTOFS_DEV_IOCTL_SIZE		sizeof(struct autofs_dev_ioctl)
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] autofs - fix AT_NO_AUTOMOUNT not being honored Ian Kent <raven@themaw.net> - 2017-08-08 06:40 +0200
  [PATCH 3/3] autofs - make dev ioctl version and ismountpoint user  accessible Ian Kent <raven@themaw.net> - 2017-08-08 06:40 +0200
  Re: [PATCH 1/3] autofs - fix AT_NO_AUTOMOUNT not being honored Colin Walters <walters@verbum.org> - 2017-08-08 15:20 +0200
    Re: [PATCH 1/3] autofs - fix AT_NO_AUTOMOUNT not being honored Ian Kent <raven@themaw.net> - 2017-08-09 02:50 +0200
  Re: [PATCH 1/3] autofs - fix AT_NO_AUTOMOUNT not being honored David Howells <dhowells@redhat.com> - 2017-08-09 10:40 +0200
    Re: [PATCH 1/3] autofs - fix AT_NO_AUTOMOUNT not being honored Ian Kent <raven@themaw.net> - 2017-08-09 12:00 +0200
      Re: [PATCH 1/3] autofs - fix AT_NO_AUTOMOUNT not being honored Ian Kent <raven@themaw.net> - 2017-08-10 04:20 +0200

csiph-web