History

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.

Hans Holmberg committed 1 year ago

Commit 0d92a3e1 parent 08d33391 file · +1 −0Browse files

Unified · Split

drivers/block/null_blk/main.c+1−0
@@ -1949,6 +1949,7 @@ static int null_add_dev(struct nullb_device *dev) · 1948 unmodified lines
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;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t