Re: [RFC PATCH 0/8] block: fix bio_add_XXX_page() return type

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

 



On 5/21/21 04:32, Matthew Wilcox wrote:
> On Wed, May 19, 2021 at 11:22:47PM -0700, Chaitanya Kulkarni wrote:
>> The helper functions bio_add_XXX_page() returns the length which is
>> unsigned int but the return type of those functions is defined
>> as int instead of unsigned int.
> I've been thinking about this for a few weeks as part of the folio
> patches:
>
> https://lore.kernel.org/linux-fsdevel/20210505150628.111735-72-willy@xxxxxxxxxxxxx/
>
>  - len and off are measured in bytes
>  - neither are permitted to be negative
>  - for efficiency we only permit them to be up to 4GB
>
> I therefore believe the correct type for these parameters to be size_t,
> and we should range-check them if they're too large.  they should
> actually always fit within the page that they're associated with, but
> people do allocate non-compound pages and i'm not trying to break that
> today.
>
> using size_t makes it clear that these are byte counts, not (eg) sector
> counts.  i do think it's good to make the return value unsigned so we
> don't have people expecting a negative errno on failure.
>

Sounds good, I'll wait for few days for the feedback from others and then
send out the V1 with your suggestions for using size_t and bounds check.






[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