Re: [PATCH] block: fix BLKSECDISCARD zero-length range causing page cache invalidation

Zizhi Wo <[email protected]>
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

在 2026/7/25 3:39, Bart Van Assche 写道:
> On 7/4/26 12:39 AM, Zizhi Wo wrote:
>> Commit 697ba0b6ec4a ("block: fix integer overflow in BLKSECDISCARD") 
>> fixed
>> the start+len overflow via check_add_overflow() but did not handle the
>> start=0, len=0 case. There, start + len = 0, so end = 0 passes all 
>> checks,
>> and truncate_bdev_range()->truncate_inode_pages_range() is then called 
>> with
>> lend=UINT64_MAX, whitch is the "truncate to the end of file" sentinel, so
>> the entire page cache is invalidated.
>>
>> Fix this by replacing the validation with blk_validate_byte_range(), 
>> which
>> already rejects a zero-length range and is what BLKDISCARD uses. This 
>> also
>> switches the alignment check from a hardcoded 512 to
>> bdev_logical_block_size().
> 
> A Fixes: tag is missing. Once this has been addressed, feel free to add:
> 
> Reviewed-by: Bart Van Assche <[email protected]>
> 


Thanks for the reminder, I will add a fixtag in the second version.

Thanks,
Zizhi Wo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.