From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796083034; b=evwRxkjtcwHZ5xWKAOubUBEfWx3TcCvs3ZyS6wIS4Ic/sBsB+qlxsTOrsgaKzHH3N7x5 J2BJofOsS5i9KDP7ym3Ibx1lJfwYBXG7zoMVAm8jWH/8KeOR/sBwS21Kuy0JF/gwrrgKc qIRVeOrqv5fE64pEcXBSuf6CNxlcvGgxiTXUkG8f/GBrllRNlTJ1VRC7l3m0Z8Dv4wL66 2bBNJz8WdmlC600GykAk5sR0QBod2UheBWQQCgsS7Q4z0EoUkIwe5HZ0XRuKfJyqqsXJx SASdb4PFyaJM5V9/Ajey/cQ/Abw+yfakcV2WkpbhYDbze2HqHJ8uZyKZNWwjBPt79Lg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796083034; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=sKDNGXqlBTFmhKZM9dBGds0J/b7Els+Pe7+xBAR57E4=; b=cbhCztXy5HLJZoaF4c84OIY7gxEvs44o2Kx9gtzSUjpSSYF37C36MVQjHZJ4MxfrVs+L GtAfRUX+MXn2eXesRq5rjOKA8A6lMPzxV0zF2fqYSo0igkaGpDGczMWq13CDhoo9oIBBq iAR3EzLCiHS8Ntr04clrltl4l9lUiaNmIPJAJ+rb846kgtqWU5awpU80DM0JYjpWVgZ4P q7rrauwS6sh4N3ZYZ6zETxbiUPHRoe9+vXWP4z7Vls5Jk9MV3IznBVaba3m8mWHobgvcQ 6f9XQBiDhMu653YJ4vVwLCEDNy4E2YCUAOVsGfXFnUyFQYcPcJmfspPd6jQLCwNXPFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="XcY/jNoW"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1F2C606A31A; Mon, 30 Nov 2026 23:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XcY/jNoW Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA21D1F000C1; Mon, 30 Nov 2026 23:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796083034; bh=sKDNGXqlBTFmhKZM9dBGds0J/b7Els+Pe7+xBAR57E4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=XcY/jNoWQG4c3eBVSLRAz1GJeoHHf3lASfKqhH6AM9KQ4KZdv0nGWhQoEe97T3tGW ABKATh+tPb903AIdFwXJmwCB1ssQBKJ1Ddl/jhWMO3RYZoigqhIsIEL13qDc1NG9lz Oy3KWjdn38EsPRH69D+yPQHLrRWQhpBKYtXMS45MzLfOnq7lZ74hAjcGGvMfAD1cLn 9IVenPe5+tyxSLbNZSJZnT8e2pgPUvLNSmu0A0LkxM/8NQLsaUiM+Jtt/IBf8S45O3 D6bQCkgAmn8huN7yjTEr/bZUAda+Zth9ohAaNZBrjFgzweVF7sBb0ERQwL9G4Co1Wg r4aFUV7Z9w5kg== Subject: Re: [PATCH net] udp: drop skb extensions before deferring the free of a consumed skb From: netdev-bot+sashiko@kernel.org To: opensource@andrii.net Cc: willemdebruijn.kernel@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, sd@queasysnail.net, steffen.klassert@secunet.com, netdev@vger.kernel.org, stable@vger.kernel.org Date: Mon, 30 Nov 2026 23:57:13 +0000 Message-ID: <179608303318.3146.3152537105022972219@kernel.org> In-Reply-To: References: X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 (1) · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The new skb_ext_reset(skb) in skb_consume_udp() (net/ipv4/udp.c:1869) drops extensions only on the head skb. Pre-existing issues: - [High] TCP has the same deferred-free problem this patch fixes for UDP, and it is not fixed. -- udp: drop skb extensions before deferring the free of a consumed skb This patch calls skb_ext_reset() in skb_consume_udp() before a consumed, unshared skb is handed to skb_attempt_defer_free(). The goal is to stop a datagram's secpath, and the xfrm states it references, from waiting on a remote CPU's defer list after their network namespace is gone. Link: https://lore.kernel.org/netdev/20251014060454.1841122-1-edumazet@google.com/ > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c > index d784faf939c3b..365d924c77c5a 100644 > --- a/net/ipv4/udp.c > +++ b/net/ipv4/udp.c > @@ -1862,6 +1862,11 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len) > > if (!skb_shared(skb)) { > skb_orphan(skb); > + /* A deferred skb can wait on another CPU's list indefinitely, > + * and its secpath holds xfrm states. recvmsg() has already > + * used the secpath for IP_CMSG_PASSSEC: drop all extensions. > + */ > + skb_ext_reset(skb); [Severity: High] Does this cover reassembled datagrams? skb_ext_reset() drops extensions only on the head skb. Fragments that were not coalesced stay on skb_shinfo(head)->frag_list, and each keeps its own skb_ext and sec_path. In tunnel mode the inner packet is fragmented before encapsulation, so xfrm_input() gives each fragment its own secpath. inet_frag_queue_insert() only checks that the secpaths match: net/ipv4/inet_fragment.c:inet_frag_queue_insert() { ... /* The reassembled skb keeps the first fragment's secpath. */ if (last && !secpath_equal(last, skb)) return IPFRAG_MIXED_SECPATH; ... } inet_frag_reasm_finish() then links the non-coalesced fragments into frag_list and leaves their extensions alone: net/ipv4/inet_fragment.c:inet_frag_reasm_finish() { ... if (try_coalesce && skb_try_coalesce(head, fp, &stolen, &delta)) { kfree_skb_partial(fp, stolen); } else { fp->prev = NULL; memset(&fp->rbnode, 0, sizeof(fp->rbnode)); fp->sk = NULL; ... *nextp = fp; nextp = &fp->next; } ... } nf_ct_frag6_reasm() passes try_coalesce as false. With IPv6 conntrack defrag active in the netns, every non-head fragment therefore lands on frag_list. ipv6/reassembly.c passes true, but skb_try_coalesce() can still fail. skb_attempt_defer_free(head) then queues the head and its frag_list on the remote CPU. The fragments' xfrm_state references are dropped only when that CPU flushes its list: skb_attempt_defer_free(head) ... remote CPU flush ... skb_release_data() kfree_skb_list(frag_list) skb_ext_put() With a UDP datagram larger than the inner MTU, can the xfrm6_tunnel_net_exit() warning and xfrm6_tunnel_destroy() use-after-free from the commit message still happen? Do the frag_list skbs need their extensions released here too, or should skbs like these not be deferred at all? > skb_attempt_defer_free(skb); > return; > } [Severity: High] This isn't a bug introduced by this patch, but does TCP have the same problem? The commit message says secpath_reset() alone is not enough, and TCP uses only that: include/net/tcp.h:tcp_cleanup_skb() { skb_dst_drop(skb); secpath_reset(skb); } If another extension is active and the ext is shared with a clone, __skb_ext_del() clears the active bit and returns without calling skb_ext_put_sp(): net/core/skbuff.c:__skb_ext_del() { ... skb->active_extensions &= ~(1 << id); if (skb->active_extensions == 0) { ... } if (refcount_read(&ext->refcnt) > 1) return; ... } tcp_eat_recv_skb() then defers the free without calling skb_ext_reset(): net/ipv4/tcp.c:tcp_eat_recv_skb() { ... if (likely(skb->destructor == sock_rfree)) { sock_rfree(skb); skb->destructor = NULL; skb->sk = NULL; return skb_attempt_defer_free(skb); } ... } Here is one possible sequence: - A bridged skb keeps SKB_EXT_BRIDGE_NF (or TC_SKB_EXT) through local delivery. - xfrm_input() adds SEC_PATH to the same ext. - packet_rcv() clones the skb for an AF_PACKET tap. If the packet socket's clone is freed first, the deferred TCP skb holds the last ext reference. __skb_ext_put() then releases the xfrm states only when the remote CPU flushes its defer list. MPTCP already calls skb_ext_reset() in __mptcp_move_skb() before its skbs reach the defer path. That seems to leave TCP as the only skb_attempt_defer_free() caller that relies on secpath_reset() alone. Should tcp_eat_recv_skb() or tcp_cleanup_skb() also call skb_ext_reset()? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/c3d49b69-bd8d-4c34-b02d-60b64d175610%40mid.andrii.net