]> git.ipfire.org Git - thirdparty/linux.git/commit
null_blk: set dma alignment to logical block size
authorHans Holmberg <hans.holmberg@wdc.com>
Fri, 31 Oct 2025 09:48:26 +0000 (10:48 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 31 Oct 2025 15:03:12 +0000 (09:03 -0600)
commit0d92a3eaa6726e64a18db74ece806c2c021aaac3
treefe97f1280a126437cd10d7f14fc02d920b1defce
parent08d33390248f9e248bca970afc731a16aad4e348
null_blk: set dma alignment to logical block size

This driver assumes that bio vectors are memory aligned to the logical
block size, so set the queue limit to reflect that.

Unless we set up the limit based on the logical block size, we will go
out of page bounds in copy_to_nullb / copy_from_nullb.

Apparently this wasn't noticed so far because none of the tests generate
such buffers, but since commit 851c4c96db00 ("xfs: implement
XFS_IOC_DIOINFO in terms of vfs_getattr") xfstests generates unaligned
I/O, which now lead to memory corruption when using null_blk devices
with 4k block size.

Fixes: bf8d08532bc1 ("iomap: add support for dma aligned direct-io")
Fixes: b1a000d3b8ec ("block: relax direct io memory alignment")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk/main.c