Skip to content
Commit b58b1b88 authored by Brian Foster's avatar Brian Foster Committed by Kent Overstreet
Browse files

bcachefs: fix iov_iter count underflow on sub-block dio read



bch2_direct_IO_read() checks the request offset and size for sector
alignment and then falls through to a couple calculations to shrink
the size of the request based on the inode size. The problem is that
these checks round up to the fs block size, which runs the risk of
underflowing iter->count if the block size happens to be large
enough. This is triggered by fstest generic/361 with a 4k block
size, which subsequently leads to a crash. To avoid this crash,
check that the shorten length doesn't exceed the overall length of
the iter.

Fixes:
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarSu Yue <glass.su@suse.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 204f4514
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment