Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Antony Antony
Mon, 19 Oct 2026 12:35
Re: [PATCH net-next v3 4/6] net: skbuff: replace __skb_frag_ref() with symmetric skb_netmem_ref()
Author: Antony Antony
Date: Mon, 19 Oct 2026 12:35
Date: Mon, 19 Oct 2026 12:35
48 lines
10251 bytes
10251 bytes
On Wed, Oct 14, 2026 at 17:37:18 +0000, Mina Almasry wrote:
> Previously, __skb_frag_ref() and skb_frag_ref() unconditionally
> incremented the non-pp backing refcount via get_netmem(), while
> skb_frag_unref() decremented pp_ref_count whenever skb->pp_recycle was
> set. Ref-ing a page_pool fragment into a pp_recycle=1 SKB (or clearing
> pp_recycle=0 on an uncloned SKB while clones still held pp_recycle=1)
> leaked the backing non-pp refcount and underflowed pp_ref_count across
> IP-TFS, skb_split(), skb_shift(), and cloned unclone paths.
>
> Replace __skb_frag_ref() with skb_netmem_ref(netmem, recycle) as the
> exact counterpart to skb_netmem_unref(netmem, recycle):
>
> - Keep skb->pp_recycle intact in skb_release_data() so uncloning paths
> (pskb_expand_head() and pskb_carve_inside_{header,nonlinear}()) keep
> trading pp_ref_count references symmetrically across clones.
> - Propagate pp_recycle and call skb_frag_ref() on the destination SKB in
> __pskb_copy_fclone(), skb_zerocopy(), skb_split(), skb_shift(), and
> skb_segment().
> - Linearize an output segment's existing frags in skb_segment() before
> attaching frags from a frag_list SKB with a different pp_recycle bit,
> since each output segment carries a single pp_recycle bit.
> - Use skb_frag_ref() in xfrm_iptfs, chcr_ktls, and cassini, and call
> get_netmem() directly in veth and tls_device_fallback where callers
> explicitly take a raw non-pp reference.
>
> Found by code inspection while reviewing the IP-TFS pp_ref_count fix [1]
> and confirmed with the KUnit tests added later in this series; not
> observed in production. The xfrm_iptfs, chcr_ktls, cassini, veth, and
> tls_device_fallback changes are compile-tested only.
>
> Link: https://lore.kernel.org/netdev/xfrm-iptfs-pp_ref_count-underflow-v4-1-912fa72106f0@secunet.com/ [1]
> Cc: Antony Antony <antony.antony@secunet.com>
> Cc: Stanislav Fomichev <sdf@fomichev.me>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Jesper Dangaard Brouer <hawk@kernel.org>
> Cc: bpf@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Mina Almasry <almasrymina@google.com>
Tested-by: Antony Antony <antony.antony@secunet.com>
I tested for IP-TFS virtio.
Steffen, if this patch is applied, the following will become redundant:
https://patchwork.kernel.org/project/netdevbpf/patch/xfrm-iptfs-pp_ref_count-underflow-v5-1-c25508ec9160@secunet.com/
-antony
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads