Skip to content

Commit 0d92a3e

Browse files
yhraxboe
authored andcommitted
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 851c4c9 ("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: bf8d085 ("iomap: add support for dma aligned direct-io") Fixes: b1a000d ("block: relax direct io memory alignment") Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Signed-off-by: Hans Holmberg <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 08d3339 commit 0d92a3e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/block/null_blk/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,7 @@ static int null_add_dev(struct nullb_device *dev)
19491949
.logical_block_size = dev->blocksize,
19501950
.physical_block_size = dev->blocksize,
19511951
.max_hw_sectors = dev->max_sectors,
1952+
.dma_alignment = dev->blocksize - 1,
19521953
};
19531954

19541955
struct nullb *nullb;

0 commit comments

Comments
 (0)