Re: [PATCH 1/2] bcache: avoid nr_stripes overflow in bcache_device_init()

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

 



On 2020/7/13 04:37, Jens Axboe wrote:
> On 7/12/20 11:47 AM, Coly Li wrote:
>> For some block devices which large capacity (e.g. 8TB) but small io_opt
>> size (e.g. 8 sectors), in bcache_device_init() the stripes number calcu-
>> lated by,
>> 	DIV_ROUND_UP_ULL(sectors, d->stripe_size);
>> might be overflow to the unsigned int bcache_device->nr_stripes.
>>
>> This patch uses an unsigned long variable to store DIV_ROUND_UP_ULL()
>> and after the value is checked to be available in unsigned int range,
>> sets it to bache_device->nr_stripes. Then the overflow is avoided.
> 
> Does that work on 32-bit, where sizeof(unsigned long) == 4?
> 

I will post v2 to explicit use uint64_t. Thanks for the remind.

Coly Li



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux