Patch "virtio_net: bugfix overflow inside xdp_linearize_page()" has been added to the 4.14-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_net: bugfix overflow inside xdp_linearize_page()

to the 4.14-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_net-bugfix-overflow-inside-xdp_linearize_page.patch
and it can be found in the queue-4.14 subdirectory.

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



commit a86095697d9569abb36e11e7eafa44956f48473b
Author: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx>
Date:   Fri Apr 14 14:08:35 2023 +0800

    virtio_net: bugfix overflow inside xdp_linearize_page()
    
    [ Upstream commit 853618d5886bf94812f31228091cd37d308230f7 ]
    
    Here we copy the data from the original buf to the new page. But we
    not check that it may be overflow.
    
    As long as the size received(including vnethdr) is greater than 3840
    (PAGE_SIZE -VIRTIO_XDP_HEADROOM). Then the memcpy will overflow.
    
    And this is completely possible, as long as the MTU is large, such
    as 4096. In our test environment, this will cause crash. Since crash is
    caused by the written memory, it is meaningless, so I do not include it.
    
    Fixes: 72979a6c3590 ("virtio_net: xdp, add slowpath case for non contiguous buffers")
    Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx>
    Acked-by: Jason Wang <jasowang@xxxxxxxxxx>
    Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9e18389309cf4..067ebdd0d5898 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -452,8 +452,13 @@ static struct page *xdp_linearize_page(struct receive_queue *rq,
 				       int page_off,
 				       unsigned int *len)
 {
-	struct page *page = alloc_page(GFP_ATOMIC);
+	int tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+	struct page *page;
 
+	if (page_off + *len + tailroom > PAGE_SIZE)
+		return NULL;
+
+	page = alloc_page(GFP_ATOMIC);
 	if (!page)
 		return NULL;
 



[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