Netdev List
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: dickson.wu@certik.com
Cc: netdev@vger.kernel.org, John Fastabend <john.fastabend@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>
Subject: Re: [PATCH net] tls: rx: fix skb extension reference leak
Date: Mon, 30 Nov 2026 17:22:39 +0100	[thread overview]
Message-ID: <aw2iz0w3zt_6uHmJ@krikkit> (raw)
In-Reply-To: <20261127-ktls-net-v1-1-a047fdb54612@certik.com>

(dropped security@ since this is public)

2026-11-27, 08:47:22 +0000, Dickson Wu via B4 Relay wrote:
> From: Dickson Wu <dickson.wu@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/bd169df0-f88c-417b-91aa-c9b0f11a28b8@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/cover.1782123118.git.tanggeliang@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

      reply	other threads:[~2026-11-30 16:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  8:47 [PATCH net] tls: rx: fix skb extension reference leak Dickson Wu via B4 Relay
2026-11-30 16:22 ` Sabrina Dubroca [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw2iz0w3zt_6uHmJ@krikkit \
    --to=sd@queasysnail.net \
    --cc=davem@davemloft.net \
    --cc=dickson.wu@certik.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox