(dropped security@ since this is public) 2026-11-27, 08:47:22 +0000, Dickson Wu via B4 Relay wrote:
> From: Dickson Wu <dick…@certik.com> > > tls_strp_load_anchor_with_queue() reuses strp->anchor for every record > and calls skb_copy_header() to copy the header of the first queued skb > onto it. skb_copy_header() goes through __copy_skb_header(), which uses > __skb_ext_copy(): it takes a reference on the source skb's extensions > and overwrites the anchor's extension pointer without dropping the > reference the anchor already held. When the received skbs carry > extensions, for example TC_SKB_EXT set by tc or SKB_EXT_BRIDGE_NF set > by br_netfilter, every reload of the anchor leaks one skb_ext.
Once we have https://lore.kernel.org/all/bd16…@mid.andrii.net/ tls_strp will not receive skbs with any extensions (MPTCP and PSP combined with TLS should not be valid [1]), and it's the only case where we would still have extensions? [1] well, for now at least https://lore.kernel.org/all/cove…@kylinos.cn/ but keeping the MPTCP extension that late after MPTCP doesn't make sense so MPTCP should also drop them before the skb reaches TLS.
> skbuff_ext_cache is not charged to the memory cgroup, so the leaked > objects also escape memcg limits. > > Drop the anchor's extensions with skb_ext_reset() before copying the > new header.
If we go with this, I think it would make more sense to do it as soon as we're done with the current record, instead of waiting until we start working on the new one.
> diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c > index 53d3256d0..8ad7f339d 100644 > --- a/net/tls/tls_strp.c > +++ b/net/tls/tls_strp.c > @@ -475,6 +475,7 @@ static void tls_strp_load_anchor_with_queue(struct tls_strparser *strp, int len) > > skb_shinfo(strp->anchor)->frag_list = first; > > + skb_ext_reset(strp->anchor); > skb_copy_header(strp->anchor, first);
And probably a DEBUG_NET_WARN_ON_ONCE(skb->active_extensions) in __copy_skb_header() to help avoid this mistake.
-- Sabrina