fbdev: sbuslib: integer overflow in sbusfb_ioctl_helper()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 8 Oct 2018 10:57:36 +0000 (12:57 +0200)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Mon, 8 Oct 2018 10:57:36 +0000 (12:57 +0200)
The "index + count" addition can overflow.  Both come directly from the
user.  This bug leads to an information leak.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Peter Malone <peter.malone@gmail.com>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
drivers/video/fbdev/sbuslib.c

index 90c5133..01a7110 100644 (file)
@@ -171,7 +171,7 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
                    get_user(ublue, &c->blue))
                        return -EFAULT;
 
-               if (index + count > cmap->len)
+               if (index > cmap->len || count > cmap->len - index)
                        return -EINVAL;
 
                for (i = 0; i < count; i++) {