Patch "xsk: Fix unaligned descriptor validation" has been added to the 5.10-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 unaligned descriptor validation

to the 5.10-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-unaligned-descriptor-validation.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 6be2ddb398d70ae14cb4294b92f3e548466dbd86
Author: Kal Conley <kal.conley@xxxxxxxxxxx>
Date:   Thu Apr 6 01:59:18 2023 +0200

    xsk: Fix unaligned descriptor validation
    
    [ Upstream commit d769ccaf957fe7391f357c0a923de71f594b8a2b ]
    
    Make sure unaligned descriptors that straddle the end of the UMEM are
    considered invalid. Currently, descriptor validation is broken for
    zero-copy mode which only checks descriptors at page granularity.
    For example, descriptors in zero-copy mode that overrun the end of the
    UMEM but not a page boundary are (incorrectly) considered valid. The
    UMEM boundary check needs to happen before the page boundary and
    contiguity checks in xp_desc_crosses_non_contig_pg(). Do this check in
    xp_unaligned_validate_desc() instead like xp_check_unaligned() already
    does.
    
    Fixes: 2b43470add8c ("xsk: Introduce AF_XDP buffer allocation API")
    Signed-off-by: Kal Conley <kal.conley@xxxxxxxxxxx>
    Acked-by: Magnus Karlsson <magnus.karlsson@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230405235920.7305-2-kal.conley@xxxxxxxxxxx
    Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
index c9a47d3d8f503..5a63e3b12335a 100644
--- a/include/net/xsk_buff_pool.h
+++ b/include/net/xsk_buff_pool.h
@@ -150,13 +150,8 @@ static inline bool xp_desc_crosses_non_contig_pg(struct xsk_buff_pool *pool,
 	if (likely(!cross_pg))
 		return false;
 
-	if (pool->dma_pages_cnt) {
-		return !(pool->dma_pages[addr >> PAGE_SHIFT] &
-			 XSK_NEXT_PG_CONTIG_MASK);
-	}
-
-	/* skb path */
-	return addr + len > pool->addrs_cnt;
+	return pool->dma_pages_cnt &&
+	       !(pool->dma_pages[addr >> PAGE_SHIFT] & XSK_NEXT_PG_CONTIG_MASK);
 }
 
 static inline u64 xp_aligned_extract_addr(struct xsk_buff_pool *pool, u64 addr)
diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
index 3c7ce60fe9a5a..a76d43787549f 100644
--- a/net/xdp/xsk_queue.h
+++ b/net/xdp/xsk_queue.h
@@ -155,6 +155,7 @@ static inline bool xp_unaligned_validate_desc(struct xsk_buff_pool *pool,
 		return false;
 
 	if (base_addr >= pool->addrs_cnt || addr >= pool->addrs_cnt ||
+	    addr + desc->len > pool->addrs_cnt ||
 	    xp_desc_crosses_non_contig_pg(pool, addr, desc->len))
 		return false;
 



[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