autofs: make dev ioctl version and ismountpoint user accessible
authorIan Kent <raven@themaw.net>
Fri, 8 Sep 2017 23:16:30 +0000 (16:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 9 Sep 2017 01:26:50 +0000 (18:26 -0700)
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.

Link: http://lkml.kernel.org/r/150216642517.11652.2338933266137331637.stgit@pluto.themaw.net
Signed-off-by: Ian Kent <raven@themaw.net>
Cc: Colin Walters <walters@redhat.com>
Cc: Ondrej Holy <oholy@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/autofs4/dev-ioctl.c
include/uapi/linux/auto_dev-ioctl.h

index 218a4ecc75cc4b849fbecf5565c4772e2cb94e0d..ea8b3a1cddd20540d8c1a8be206772fa98436551 100644 (file)
@@ -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))
index 744b3d0609687b82bb198ed76c158417c22f09f9..5558db8e6646bc4abb46471b129331e8d1862b90 100644 (file)
@@ -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)