Re: [PATCH][V2] PCI: Fix a potential uninitentional integer overflow issue

From: Logan Gunthorpe
Date: Tue Nov 10 2020 - 18:55:47 EST




On 2020-11-10 3:10 p.m., Colin King wrote:
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>
> The shift of 1 by align_order is evaluated using 32 bit arithmetic
> and the result is assigned to a resource_size_t type variable that
> is a 64 bit unsigned integer on 64 bit platforms. Fix an overflow
> before widening issue by making the 1 a ULL.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")

I think this should probably be

Fixes: 32a9a682bef2 ("PCI: allow assignment of memory resources with a
specified alignment")

That is the commit where the original bug was introduced. 644a544fd9bcd
then extends the code a little bit and 07d8d7e57c28 only refactors it
into a reusable function. If we want this in older stable kernels then
we will probably need to make different patches for the other two vintages.

> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>

Besides that, the change makes sense to me.

Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>

Thanks,

Logan