Skip to contentSkip to conversation

net: strparser: fix skb_head leak in strp_abort_strp()

PATCH Applied Ren Wei 2 participants 2 messages Apr 11 – Apr 14 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ren Wei

author
#1 lore raw

PATCH 1/1 net: strparser: fix skb_head leak in strp_abort_strp()

From: Luxiao Xu <[email protected]>

When the stream parser is aborted, for example after a message assembly timeout, it can still hold a reference to a partially assembled message in strp->skb_head.

That skb is not released in strp_abort_strp(), which leaks the partially assembled message and can be triggered repeatedly to exhaust memory.

Fix this by freeing strp->skb_head and resetting the parser state in the abort path. Leave strp_stop() unchanged so final cleanup still happens in strp_done() after the work and timer have been synchronized.

Fixes 43a0c6751a32 ("strparser: Stream parser for messages")
---
 net/strparser/strparser.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/strparser/strparser.c +8 -0
index fe0e76fdd1f1..a23f4b4dfc67 100644
@@ -45,6 +45,14 @@ static void strp_abort_strp(struct strparser *strp, int err)
 
 	strp->stopped = 1;
 
+	if (strp->skb_head) {
+		kfree_skb(strp->skb_head);
+		strp->skb_head = NULL;
+	}
+
+	strp->skb_nextp = NULL;
+	strp->need_bytes = 0;
+
 	if (strp->sk) {
 		struct sock *sk = strp->sk;
 
Signature · 1 line
2.43.0
#2 lore raw
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Sat, 11 Apr 2026 23:10:10 +0800 you wrote:

From: Luxiao Xu <[email protected]>

When the stream parser is aborted, for example after a message assembly timeout, it can still hold a reference to a partially assembled message in strp->skb_head.

That skb is not released in strp_abort_strp(), which leaks the partially assembled message and can be triggered repeatedly to exhaust memory.

[...]

Here is the summary with links:
- [1/1] net: strparser: fix skb_head leak in strp_abort_strp()

    https://git.kernel.org/netdev/net/c/fe72340daaf1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html