All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio_blk: set log2blksz correctly
@ 2020-08-19  9:07 AKASHI Takahiro
  2020-08-19  9:38 ` Bin Meng
  2020-08-25 12:16 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: AKASHI Takahiro @ 2020-08-19  9:07 UTC (permalink / raw)
  To: u-boot

'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.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Fixes: f4802209e59d ("virtio: Add block driver support")
---
 drivers/virtio/virtio_blk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
index 992118c60758..1799f5c5eb36 100644
--- a/drivers/virtio/virtio_blk.c
+++ b/drivers/virtio/virtio_blk.c
@@ -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;
 
-- 
2.28.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] virtio_blk: set log2blksz correctly
  2020-08-19  9:07 [PATCH] virtio_blk: set log2blksz correctly AKASHI Takahiro
@ 2020-08-19  9:38 ` Bin Meng
  2020-08-25 12:16 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Bin Meng @ 2020-08-19  9:38 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 19, 2020 at 5:08 PM AKASHI Takahiro
<takahiro.akashi@linaro.org> wrote:
>
> '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.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Fixes: f4802209e59d ("virtio: Add block driver support")
> ---
>  drivers/virtio/virtio_blk.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] virtio_blk: set log2blksz correctly
  2020-08-19  9:07 [PATCH] virtio_blk: set log2blksz correctly AKASHI Takahiro
  2020-08-19  9:38 ` Bin Meng
@ 2020-08-25 12:16 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2020-08-25 12:16 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 19, 2020 at 06:07:32PM +0900, AKASHI Takahiro wrote:

> '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.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Fixes: f4802209e59d ("virtio: Add block driver support")
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-25 12:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19  9:07 [PATCH] virtio_blk: set log2blksz correctly AKASHI Takahiro
2020-08-19  9:38 ` Bin Meng
2020-08-25 12:16 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.