Skip to content

Commit

Permalink
autofs: make dev ioctl version and ismountpoint user accessible
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Ian Kent <[email protected]>
Cc: Colin Walters <[email protected]>
Cc: Ondrej Holy <[email protected]>
Cc: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
raven-au authored and torvalds committed Sep 9, 2017
1 parent e54c7bc commit 3dd8f7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions fs/autofs4/dev-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/linux/auto_dev-ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3dd8f7c

Please sign in to comment.