]> git.ipfire.org Git - thirdparty/linux.git/commit
iomap: adjust read range correctly for non-block-aligned positions
authorJoanne Koong <joannelkoong@gmail.com>
Mon, 22 Sep 2025 18:00:42 +0000 (11:00 -0700)
committerChristian Brauner <brauner@kernel.org>
Mon, 20 Oct 2025 18:21:25 +0000 (20:21 +0200)
commit7aa6bc3e8766990824f66ca76c19596ce10daf3e
tree916bb6b9c4322488854ab8ecc42a517265cf66c3
parentca82a7ea2299b4586af1f77daee66ee781202320
iomap: adjust read range correctly for non-block-aligned positions

iomap_adjust_read_range() assumes that the position and length passed in
are block-aligned. This is not always the case however, as shown in the
syzbot generated case for erofs. This causes too many bytes to be
skipped for uptodate blocks, which results in returning the incorrect
position and length to read in. If all the blocks are uptodate, this
underflows length and returns a position beyond the folio.

Fix the calculation to also take into account the block offset when
calculating how many bytes can be skipped for uptodate blocks.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Tested-by: syzbot@syzkaller.appspotmail.com
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/buffered-io.c