Skip to content

Commit e9ae004

Browse files
rakukuip-sourcegregkh
authored andcommitted
net: strparser: fix skb_head leak in strp_abort_strp()
commit fe72340 upstream. 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: 43a0c67 ("strparser: Stream parser for messages") Cc: stable@kernel.org Reported-by: Yifan Wu <yifanwucs@gmail.com> Reported-by: Juefei Pu <tomapufckgml@gmail.com> Co-developed-by: Yuan Tan <yuantan098@gmail.com> Signed-off-by: Yuan Tan <yuantan098@gmail.com> Suggested-by: Xin Liu <bird@lzu.edu.cn> Tested-by: Yuan Tan <yuantan098@gmail.com> Signed-off-by: Luxiao Xu <rakukuip@gmail.com> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Link: https://patch.msgid.link/ade3857a9404999ce9a1c27ec523efc896072678.1775482694.git.rakukuip@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 914c645 commit e9ae004

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

net/strparser/strparser.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ static void strp_abort_strp(struct strparser *strp, int err)
4545

4646
strp->stopped = 1;
4747

48+
if (strp->skb_head) {
49+
kfree_skb(strp->skb_head);
50+
strp->skb_head = NULL;
51+
}
52+
53+
strp->skb_nextp = NULL;
54+
strp->need_bytes = 0;
55+
4856
if (strp->sk) {
4957
struct sock *sk = strp->sk;
5058

0 commit comments

Comments
 (0)