Patch "xsk: Free skb when TX metadata options are invalid" has been added to the 6.12-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: Free skb when TX metadata options are invalid

to the 6.12-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-free-skb-when-tx-metadata-options-are-invalid.patch
and it can be found in the queue-6.12 subdirectory.

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



commit 6a9cf04d929f6ec57e44c49ac47923d6f23b85bd
Author: Felix Maurer <fmaurer@xxxxxxxxxx>
Date:   Thu Nov 14 12:30:05 2024 +0100

    xsk: Free skb when TX metadata options are invalid
    
    [ Upstream commit 0c0d0f42ffa6ac94cd79893b7ed419c15e1b45de ]
    
    When a new skb is allocated for transmitting an xsk descriptor, i.e., for
    every non-multibuf descriptor or the first frag of a multibuf descriptor,
    but the descriptor is later found to have invalid options set for the TX
    metadata, the new skb is never freed. This can leak skbs until the send
    buffer is full which makes sending more packets impossible.
    
    Fix this by freeing the skb in the error path if we are currently dealing
    with the first frag, i.e., an skb allocated in this iteration of
    xsk_build_skb.
    
    Fixes: 48eb03dd2630 ("xsk: Add TX timestamp and TX checksum offload support")
    Reported-by: Michal Schmidt <mschmidt@xxxxxxxxxx>
    Signed-off-by: Felix Maurer <fmaurer@xxxxxxxxxx>
    Reviewed-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
    Acked-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
    Acked-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Link: https://patch.msgid.link/edb9b00fb19e680dff5a3350cd7581c5927975a8.1731581697.git.fmaurer@xxxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 1140b2a120cae..b57d5d2904eb4 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -675,6 +675,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
 		len = desc->len;
 
 		if (!skb) {
+			first_frag = true;
+
 			hr = max(NET_SKB_PAD, L1_CACHE_ALIGN(dev->needed_headroom));
 			tr = dev->needed_tailroom;
 			skb = sock_alloc_send_skb(&xs->sk, hr + len + tr, 1, &err);
@@ -685,12 +687,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
 			skb_put(skb, len);
 
 			err = skb_store_bits(skb, 0, buffer, len);
-			if (unlikely(err)) {
-				kfree_skb(skb);
+			if (unlikely(err))
 				goto free_err;
-			}
-
-			first_frag = true;
 		} else {
 			int nr_frags = skb_shinfo(skb)->nr_frags;
 			struct page *page;
@@ -758,6 +756,9 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
 	return skb;
 
 free_err:
+	if (first_frag && skb)
+		kfree_skb(skb);
+
 	if (err == -EOVERFLOW) {
 		/* Drop the packet */
 		xsk_set_destructor_arg(xs->skb);




[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