From: Dickson Wu 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. 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. Fixes: 84c61fe1a75b ("tls: rx: do not use the standard strparser") Signed-off-by: Dickson Wu --- Tested on x86_64 UML with KASAN and kmemleak at v7.4-rc4: - kTLS RX receiving 5,000 one-byte records whose skbs carried TC_SKB_EXT (tc flower in a user namespace) or SKB_EXT_BRIDGE_NF (bridge with br_netfilter): skbuff_ext_cache grew by exactly 5,000 objects and kmemleak reported 4,900 to 4,978 unreferenced objects from __skb_ext_alloc. With the fix: no growth and no reports. With the fix reverted: 5,000 again. - The same kTLS traffic without extensions, and plain TCP with extensions: no leak before or after the fix. - On v6.1.193 (bridge path, run from a user namespace) kmemleak reported 3,038 leaked skb_ext objects before the fix and none after. The patch applies unchanged to 6.1.y, 6.6.y, 6.12.y and 6.18.y. A reproducer is available if it helps. This was found and the fix prepared with AI coding tools (OpenAI Codex agents, with review by Claude). I went over the analysis and the patch before signing off. net/tls/tls_strp.c | 1 + 1 file changed, 1 insertion(+) 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); strp->anchor->destructor = NULL; -- 2.43.0