virtio_blk: set log2blksz correctly
PATCH 1/1 virtio_blk: set log2blksz correctly
'log2blksz' in blk_desc structure must always be initialized, otherwise it will cause a lot of weird failures in file operations.
For example, fs_set_blk_dev[_with_part]() examines a block device against every file system with its probe function. In particular, ext4 file system's ext4_probe() will calls fs_devread() to fetch a super block. If log2blksz is 0, the actual 'read' size, i.e. block_len >> log2blksz, is much bigger than a buffer's size, and it can end up with memory corruption.
--- drivers/virtio/virtio_blk.c | 1 + 1 file changed, 1 insertion(+)
drivers/virtio/virtio_blk.c +1 -0
@@ -115,6 +115,7 @@ static int virtio_blk_probe(struct udevice *dev)return ret; desc->blksz =512 ; + desc->log2blksz =9 ; virtio_cread(dev, struct virtio_blk_config, capacity, &cap); desc->lba = cap;
Signature · 1 line
2.28.0
PATCH 1/1 virtio_blk: set log2blksz correctly
Quoted 10 lines · AKASHI Takahiro
'log2blksz' in
blk_descstructure must always be initialized, otherwise it will cause a lot of weird failures in file operations.For example, fs_set_blk_dev[_with_part]() examines a block device against every file system with its probe function. In particular, ext4 file system's
ext4_probe()will callsfs_devread()to fetch a super block. If log2blksz is 0, the actual 'read' size, i.e.block_len>> log2blksz, is much bigger than a buffer's size, and it can end up with memory corruption.
Quoted 6 lines
Signed-off-by AKASHI Takahiro <[email protected]>Fixes f4802209e59d ("virtio: Add block driver support")--- drivers/virtio/virtio_blk.c | 1 + 1 file changed, 1 insertion(+)
PATCH 1/1 virtio_blk: set log2blksz correctly
In reply to AKASHI TakahiroQuoted 9 lines · AKASHI Takahiro
'log2blksz' in
blk_descstructure must always be initialized, otherwise it will cause a lot of weird failures in file operations.For example, fs_set_blk_dev[_with_part]() examines a block device against every file system with its probe function. In particular, ext4 file system's
ext4_probe()will callsfs_devread()to fetch a super block. If log2blksz is 0, the actual 'read' size, i.e.block_len>> log2blksz, is much bigger than a buffer's size, and it can end up with memory corruption.
Quoted 3 lines
Signed-off-by AKASHI Takahiro <[email protected]>Fixes f4802209e59d ("virtio: Add block driver support")Reviewed-by Bin Meng <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/17728de8/attachment.sig>