Patch "xsk: Fix corrupted packets for XDP_SHARED_UMEM" has been added to the 5.19-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

    xsk: Fix corrupted packets for XDP_SHARED_UMEM

to the 5.19-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:
     xsk-fix-corrupted-packets-for-xdp_shared_umem.patch
and it can be found in the queue-5.19 subdirectory.

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



commit 9b1e85488975d6a7905ca6b7e9c1fbf91bdeabd4
Author: Magnus Karlsson <magnus.karlsson@xxxxxxxxx>
Date:   Fri Aug 12 13:32:59 2022 +0200

    xsk: Fix corrupted packets for XDP_SHARED_UMEM
    
    [ Upstream commit 58ca14ed98c87cfe0d1408cc65a9745d9e9b7a56 ]
    
    Fix an issue in XDP_SHARED_UMEM mode together with aligned mode where
    packets are corrupted for the second and any further sockets bound to
    the same umem. In other words, this does not affect the first socket
    bound to the umem. The culprit for this bug is that the initialization
    of the DMA addresses for the pre-populated xsk buffer pool entries was
    not performed for any socket but the first one bound to the umem. Only
    the linear array of DMA addresses was populated. Fix this by populating
    the DMA addresses in the xsk buffer pool for every socket bound to the
    same umem.
    
    Fixes: 94033cd8e73b8 ("xsk: Optimize for aligned case")
    Reported-by: Alasdair McWilliam <alasdair.mcwilliam@xxxxxxxxxxx>
    Reported-by: Intrusion Shield Team <dnevil@xxxxxxxxxxxxx>
    Signed-off-by: Magnus Karlsson <magnus.karlsson@xxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Tested-by: Alasdair McWilliam <alasdair.mcwilliam@xxxxxxxxxxx>
    Acked-by: Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx>
    Link: https://lore.kernel.org/xdp-newbies/6205E10C-292E-4995-9D10-409649354226@xxxxxxxxxxx/
    Link: https://lore.kernel.org/bpf/20220812113259.531-1-magnus.karlsson@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index f70112176b7c1..a71a8c6edf553 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -379,6 +379,16 @@ static void xp_check_dma_contiguity(struct xsk_dma_map *dma_map)
 
 static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_map)
 {
+	if (!pool->unaligned) {
+		u32 i;
+
+		for (i = 0; i < pool->heads_cnt; i++) {
+			struct xdp_buff_xsk *xskb = &pool->heads[i];
+
+			xp_init_xskb_dma(xskb, pool, dma_map->dma_pages, xskb->orig_addr);
+		}
+	}
+
 	pool->dma_pages = kvcalloc(dma_map->dma_pages_cnt, sizeof(*pool->dma_pages), GFP_KERNEL);
 	if (!pool->dma_pages)
 		return -ENOMEM;
@@ -428,12 +438,6 @@ int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
 
 	if (pool->unaligned)
 		xp_check_dma_contiguity(dma_map);
-	else
-		for (i = 0; i < pool->heads_cnt; i++) {
-			struct xdp_buff_xsk *xskb = &pool->heads[i];
-
-			xp_init_xskb_dma(xskb, pool, dma_map->dma_pages, xskb->orig_addr);
-		}
 
 	err = xp_init_dma_info(pool, dma_map);
 	if (err) {



[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