Staging: lustre: integer overflow in ioctl
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 1 Apr 2015 08:12:15 +0000 (11:12 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Apr 2015 09:07:33 +0000 (11:07 +0200)
hdr->ioc_len is a user controlled u32 so the addition can overflow,
especially on 32 bit systems.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/libcfs/linux/linux-module.c

index a5effcd9c6794b6197cd4260b561e7308a794614..e962f89683a60cdb68ee67b3070bc185d783027e 100644 (file)
@@ -57,7 +57,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
                return -EINVAL;
        }
 
-       if (hdr->ioc_len + buf >= end) {
+       if (hdr->ioc_len >= end - buf) {
                CERROR("PORTALS: user buffer exceeds kernel buffer\n");
                return -EINVAL;
        }