FAILED: patch "[PATCH] packet: use ubuf_info completion for TX_RING packets" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 9518405613863d0bf0700927a21367f5942cf058
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092952-gently-trusting-cef8@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9518405613863d0bf0700927a21367f5942cf058 Mon Sep 17 00:00:00 2001
From: Willem de Bruijn <[email protected]>
Date: Fri, 18 Sep 2026 20:47:29 -0400
Subject: [PATCH] packet: use ubuf_info completion for TX_RING packets
tpacket_snd sends skbs with frags pointing into its ring slots. Slots are released when skb->destructor is called.
A call to skb_orphan calls skb->destructor before the skb is freed. This can cause the slot to be reused while still linked into the skb.
Switch to standard zerocopy completion (ubuf_info) so the slot is only released once all references to the payload are freed or copied. Restore skb->destructor to standard sock_wfree.
The ubuf_info completion callback can be called with a NULL skb, but only from net_zcopy_put and related API, used by zerocopy implementations that hold their own reference on the uarg, such as MSG_ZEROCOPY. This uarg is only ever completed from skb_zcopy_clear, so skb is always set.
To prevent userspace from aliasing in-flight state on shared ring slots, allocate tpacket_uarg per packet, rather than per slot. This adds a small allocation to the transmit path. Use standard kmalloc to allow backporting to stable kernels.
The uarg holds an sk_wmem_alloc reference, rather than an sk_refcnt reference. packet_free_tx_ring waits on sk_wmem_alloc before freeing the ring pages. Always allocate vec->deferred for tx_ring so page-backed rings also wait on sk_wmem_alloc when skb_copy_ubufs drops page refs before calling tpacket_ubuf_complete.
Drop the tx_ring.pg_vec test that tpacket_destruct_skb performed before accessing the slot. The sk_wmem_alloc reference now guarantees that the slot is valid. The test is also not sufficient by itself, as it reads pg_vec without pg_vec_lock, so it can race with packet_set_ring.
As a result a slot is released when its payload is copied, which can be before transmission (e.g., in skb_orphan_frags_rx). If copied before skb_tx_timestamp() is called, no slot timestamp is recorded, similar to when skb_orphan() was called early in the datapath before this patch.
Revert the now unused previous skb_zcopy_.._nouarg infra.
Depends on commit 992cc9f94ca9 ("net/packet: defer vmalloc TX_RING free until skbs finish").
include/linux/skbuff.h +1 -18
@@ -1834,22 +1834,6 @@ static inline void skb_zcopy_set(struct sk_buff *skb, struct ubuf_info *uarg, } } -static inline void skb_zcopy_set_nouarg (struct sk_buff *skb,void *val) -{ -skb_shinfo (skb)->destructor_arg = (void *)((uintptr_t ) val |0x1UL ); -skb_shinfo (skb)->flags |=SKBFL_ZEROCOPY_FRAG ; -} - -static inline bool skb_zcopy_is_nouarg (struct sk_buff *skb) -{ -return (uintptr_t )skb_shinfo (skb)->destructor_arg &0x1UL ; -} - -static inline void *skb_zcopy_get_nouarg (struct sk_buff *skb) -{ -return (void *)((uintptr_t )skb_shinfo (skb)->destructor_arg & ~0x1UL ); -} -static inline void net_zcopy_put (struct ubuf_info *uarg) {if (uarg)
@@ -1872,8 +1856,7 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy_success)struct ubuf_info *uarg =skb_zcopy (skb);if (uarg) { -if (!skb_zcopy_is_nouarg (skb)) - uarg->ops->complete (skb, uarg, zerocopy_success); + uarg->ops->complete (skb, uarg, zerocopy_success);skb_shinfo (skb)->flags &= ~SKBFL_ALL_ZEROCOPY ; }
net/packet/af_packet.c +64 -38
158 lines not on this page · raw message