We copy "hdr->ioc_len" from the user twice but we only verify that it's
within the limit on the first copy. Otherwise we could read unmapped
memory and Oops.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
{
struct libcfs_ioctl_hdr *hdr;
struct libcfs_ioctl_data *data;
+ int orig_len;
int err;
hdr = (struct libcfs_ioctl_hdr *)buf;
return -EINVAL;
}
+ orig_len = hdr->ioc_len;
err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
if (err)
return err;
+ if (orig_len != data->ioc_len)
+ return -EINVAL;
if (libcfs_ioctl_is_invalid(data)) {
CERROR("PORTALS: ioctl not correctly formatted\n");
OBD_FREE_LARGE(*buf, hdr.ioc_len);
return err;
}
+ if (hdr.ioc_len != data->ioc_len)
+ return -EINVAL;
if (obd_ioctl_is_invalid(data)) {
CERROR("ioctl not correctly formatted\n");