Re: lib/scatterlist.c : sgl_alloc_order promises more than it delivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-09-24 18:46, Douglas Gilbert wrote:
>         /* Check for integer overflow */
>         if (length > (nent << (PAGE_SHIFT + order)))
>                 return NULL;
> 
> Well _integers_ don't wrap, but that pedantic point aside, 'nent' is an
> unsigned int which means the rhs expression cannot represent 2^32 or
> higher. So if length >= 2^32 the function fails (i.e. returns NULL).
> 
> On 8 GiB and 16 GiB machines I can easily build 6 or 12 GiB sgl_s (with
> scsi_debug) but only if no single allocation is >= 4 GiB due to the
> above check.
> 
> So is the above check intended to do that or is it a bug?

The above check verifies that nent << (PAGE_SHIFT + order) ==
(uint64_t)nent << (PAGE_SHIFT + order). So I think it does what the
comment says it does.

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux