staging: lustre: libcfs: test if userland data is to small
authorLiang Zhen <liang.zhen@intel.com>
Tue, 22 Mar 2016 23:03:57 +0000 (19:03 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Mar 2016 14:30:36 +0000 (07:30 -0700)
Ensure that user land data is at least the smallest size.

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/libcfs/linux/linux-module.c

index 35e2fcf..ae05895 100644 (file)
@@ -73,6 +73,11 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
                return -EINVAL;
        }
 
+       if (hdr.ioc_len < sizeof(struct libcfs_ioctl_data)) {
+               CERROR("libcfs ioctl: user buffer too small for ioctl\n");
+               return -EINVAL;
+       }
+
        if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) {
                CERROR("libcfs ioctl: user buffer is too large %d/%d\n",
                       hdr.ioc_len, LIBCFS_IOC_DATA_MAX);