linux/drivers/block/null_blk
Hans Holmberg 0d92a3eaa6 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 851c4c96db ("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: bf8d08532b ("iomap: add support for dma aligned direct-io")
Fixes: b1a000d3b8 ("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>
2025-10-31 09:03:12 -06:00
..
Kconfig block: null_blk: make fault-injection dynamically configurable per device 2023-04-13 07:38:55 -06:00
Makefile
main.c null_blk: set dma alignment to logical block size 2025-10-31 09:03:12 -06:00
null_blk.h null_blk: do partial IO for bad blocks 2025-03-03 11:17:52 -07:00
trace.c
trace.h null_blk: Fix two sparse warnings 2024-05-13 17:51:17 -06:00
zoned.c null_blk: do partial IO for bad blocks 2025-03-03 11:17:52 -07:00