From: Liang Zhen Date: Tue, 22 Mar 2016 23:03:57 +0000 (-0400) Subject: staging: lustre: libcfs: test if userland data is to small X-Git-Tag: Ubuntu-5.13.0-19.19~15742^2~671 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ed2f549dc0f687f5d454cb20754340e83e5b9c4f;p=mirror_ubuntu-jammy-kernel.git staging: lustre: libcfs: test if userland data is to small Ensure that user land data is at least the smallest size. Signed-off-by: Liang Zhen Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435 Reviewed-on: http://review.whamcloud.com/11313 Reviewed-by: Bobi Jam Reviewed-by: Johann Lombardi Reviewed-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c index 35e2fcf238e1..ae058956f209 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c @@ -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);