staging: vc04_services: prevent integer overflow in create_pagelist()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 15 May 2019 09:38:33 +0000 (12:38 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 May 2019 07:26:04 +0000 (09:26 +0200)
commitca641bae6da977d638458e78cd1487b6160a2718
tree3f24b8331b82d8cbd7675298dccb8c3518538408
parentca4e4efbefbbdde0a7bb3023ea08d491f4daf9b9
staging: vc04_services: prevent integer overflow in create_pagelist()

The create_pagelist() "count" parameter comes from the user in
vchiq_ioctl() and it could overflow.  If you look at how create_page()
is called in vchiq_prepare_bulk_data(), then the "size" variable is an
int so it doesn't make sense to allow negatives or larger than INT_MAX.

I don't know this code terribly well, but I believe that typical values
of "count" are typically quite low and I don't think this check will
affect normal valid uses at all.

The "pagelist_size" calculation can also overflow on 32 bit systems, but
not on 64 bit systems.  I have added an integer overflow check for that
as well.

The Raspberry PI doesn't offer the same level of memory protection that
x86 does so these sorts of bugs are probably not super critical to fix.

Fixes: 71bad7f08641 ("staging: add bcm2708 vchiq driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c