Commit 02f51d45 authored by Tomas Bortoli's avatar Tomas Bortoli Committed by Linus Torvalds

autofs: fix slab out of bounds read in getname_kernel()

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/153060031527.26631.18306637892746301555.stgit@pluto.themaw.netSigned-off-by: default avatarTomas Bortoli <tomasbortoli@gmail.com>
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Reported-by: syzbot+60c837b428dc84e83a93@syzkaller.appspotmail.com
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e70cc2bd
...@@ -135,6 +135,15 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param) ...@@ -135,6 +135,15 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
cmd); cmd);
goto out; 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; err = 0;
...@@ -271,7 +280,8 @@ static int autofs_dev_ioctl_openmount(struct file *fp, ...@@ -271,7 +280,8 @@ static int autofs_dev_ioctl_openmount(struct file *fp,
dev_t devid; dev_t devid;
int err, fd; int err, fd;
/* param->path has already been checked */ /* param->path has been checked in validate_dev_ioctl() */
if (!param->openmount.devid) if (!param->openmount.devid)
return -EINVAL; return -EINVAL;
...@@ -433,10 +443,7 @@ static int autofs_dev_ioctl_requester(struct file *fp, ...@@ -433,10 +443,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
dev_t devid; dev_t devid;
int err = -ENOENT; int err = -ENOENT;
if (param->size <= AUTOFS_DEV_IOCTL_SIZE) { /* param->path has been checked in validate_dev_ioctl() */
err = -EINVAL;
goto out;
}
devid = sbi->sb->s_dev; devid = sbi->sb->s_dev;
...@@ -521,10 +528,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, ...@@ -521,10 +528,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
unsigned int devid, magic; unsigned int devid, magic;
int err = -ENOENT; int err = -ENOENT;
if (param->size <= AUTOFS_DEV_IOCTL_SIZE) { /* param->path has been checked in validate_dev_ioctl() */
err = -EINVAL;
goto out;
}
name = param->path; name = param->path;
type = param->ismountpoint.in.type; type = param->ismountpoint.in.type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment