Patch "virtio-blk: fix implicit overflow on virtio_max_dma_size" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    virtio-blk: fix implicit overflow on virtio_max_dma_size

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     virtio-blk-fix-implicit-overflow-on-virtio_max_dma_s.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bca31ff5bc45b85b2081a424b1095dd57cef0f18
Author: zhenwei pi <pizhenwei@xxxxxxxxxxxxx>
Date:   Mon Sep 4 14:10:45 2023 +0800

    virtio-blk: fix implicit overflow on virtio_max_dma_size
    
    [ Upstream commit fafb51a67fb883eb2dde352539df939a251851be ]
    
    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@xxxxxxxxxxxxx>
    Message-Id: <20230904061045.510460-1-pizhenwei@xxxxxxxxxxxxx>
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index d2ba849bb8d19..affeca0dbc7ea 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -743,6 +743,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",
@@ -844,7 +845,8 @@ static int virtblk_probe(struct virtio_device *vdev)
 	/* No real sector limit. */
 	blk_queue_max_hw_sectors(q, -1U);
 
-	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. */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux