Skip to content

Commit

Permalink
autofs: fix slab out of bounds read in getname_kernel()
Browse files Browse the repository at this point in the history
The autofs subsystem does not check that the "path" parameter is present
for all cases where it is required when it is passed in via the "param"
struct.

In particular it isn't checked for the AUTOFS_DEV_IOCTL_OPENMOUNT_CMD
ioctl command.

To solve it, modify validate_dev_ioctl(function to check that a path has
been provided for ioctl commands that require it.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Tomas Bortoli <[email protected]>
Signed-off-by: Ian Kent <[email protected]>
Reported-by: [email protected]
Cc: Dmitry Vyukov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Tomas Bortoli authored and torvalds committed Jul 14, 2018
1 parent e70cc2b commit 02f51d4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fs/autofs/dev-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
cmd);
goto out;
}
} else {
unsigned int inr = _IOC_NR(cmd);

if (inr == AUTOFS_DEV_IOCTL_OPENMOUNT_CMD ||
inr == AUTOFS_DEV_IOCTL_REQUESTER_CMD ||
inr == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD) {
err = -EINVAL;
goto out;
}
}

err = 0;
Expand Down Expand Up @@ -271,7 +280,8 @@ static int autofs_dev_ioctl_openmount(struct file *fp,
dev_t devid;
int err, fd;

/* param->path has already been checked */
/* param->path has been checked in validate_dev_ioctl() */

if (!param->openmount.devid)
return -EINVAL;

Expand Down Expand Up @@ -433,10 +443,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
dev_t devid;
int err = -ENOENT;

if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
err = -EINVAL;
goto out;
}
/* param->path has been checked in validate_dev_ioctl() */

devid = sbi->sb->s_dev;

Expand Down Expand Up @@ -521,10 +528,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
unsigned int devid, magic;
int err = -ENOENT;

if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
err = -EINVAL;
goto out;
}
/* param->path has been checked in validate_dev_ioctl() */

name = param->path;
type = param->ismountpoint.in.type;
Expand Down

0 comments on commit 02f51d4

Please sign in to comment.