From: zhenwei pi <pizhenwei@bytedance.com>
To: mst@redhat.com
Cc: jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
virtualization@lists.linux-foundation.org, axboe@kernel.dk,
linux-kernel@vger.kernel.org
Subject: PING: [PATCH] virtio-blk: fix implicit overflow on virtio_max_dma_size
Date: Thu, 19 Oct 2023 17:43:55 +0800 [thread overview]
Message-ID: <dedde8ee-6edb-4950-aa8b-e89e025440b7@bytedance.com> (raw)
In-Reply-To: <20230904061045.510460-1-pizhenwei@bytedance.com>
Hi Michael,
This seems to have been ignored as you suggested.
LINK: https://www.spinics.net/lists/linux-virtualization/msg63015.html
On 9/4/23 14:10, zhenwei pi wrote:
> The following codes have an implicit conversion from size_t to u32:
> (u32)max_size = (size_t)virtio_max_dma_size(vdev);
>
> This may lead overflow, Ex (size_t)4G -> (u32)0. Once
> virtio_max_dma_size() has a larger size than U32_MAX, use U32_MAX
> instead.
>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> ---
> drivers/block/virtio_blk.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 1fe011676d07..4a4b9bad551e 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -1313,6 +1313,7 @@ static int virtblk_probe(struct virtio_device *vdev)
> u16 min_io_size;
> u8 physical_block_exp, alignment_offset;
> unsigned int queue_depth;
> + size_t max_dma_size;
>
> if (!vdev->config->get) {
> dev_err(&vdev->dev, "%s failure: config access disabled\n",
> @@ -1411,7 +1412,8 @@ static int virtblk_probe(struct virtio_device *vdev)
> /* No real sector limit. */
> blk_queue_max_hw_sectors(q, UINT_MAX);
>
> - max_size = virtio_max_dma_size(vdev);
> + max_dma_size = virtio_max_dma_size(vdev);
> + max_size = max_dma_size > U32_MAX ? U32_MAX : max_dma_size;
>
> /* Host can optionally specify maximum segment size and number of
> * segments. */
--
zhenwei pi
next prev parent reply other threads:[~2023-10-19 9:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 6:10 zhenwei pi
2023-10-19 9:43 ` zhenwei pi [this message]
2023-10-19 9:52 ` PING: " Michael S. Tsirkin
2023-10-20 2:23 ` zhenwei pi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dedde8ee-6edb-4950-aa8b-e89e025440b7@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=axboe@kernel.dk \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome