Re: [PATCH] block: fix BLKSECDISCARD zero-length range causing page cache invalidation
Christoph Hellwig <[email protected]>
| Newsgroups | org.kernel.vger.linux-block,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Jul 04, 2026 at 03:39:42PM +0800, Zizhi Wo wrote: > From: Zizhi Wo <[email protected]> > > 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(). I though I had reviewed this before? But either way it looks good: Reviewed-by: Christoph Hellwig <[email protected]>