This is a note to let you know that I've just added the patch titled net: kcm: fix memory leak in kcm_sendmsg to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: net-kcm-fix-memory-leak-in-kcm_sendmsg.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From c47cc304990a2813995b1a92bbc11d0bb9a19ea9 Mon Sep 17 00:00:00 2001 From: Pavel Skripkin <paskripkin@xxxxxxxxx> Date: Wed, 2 Jun 2021 22:26:40 +0300 Subject: net: kcm: fix memory leak in kcm_sendmsg From: Pavel Skripkin <paskripkin@xxxxxxxxx> commit c47cc304990a2813995b1a92bbc11d0bb9a19ea9 upstream. Syzbot reported memory leak in kcm_sendmsg()[1]. The problem was in non-freed frag_list in case of error. In the while loop: if (head == skb) skb_shinfo(head)->frag_list = tskb; else skb->next = tskb; frag_list filled with skbs, but nothing was freeing them. backtrace: [<0000000094c02615>] __alloc_skb+0x5e/0x250 net/core/skbuff.c:198 [<00000000e5386cbd>] alloc_skb include/linux/skbuff.h:1083 [inline] [<00000000e5386cbd>] kcm_sendmsg+0x3b6/0xa50 net/kcm/kcmsock.c:967 [1] [<00000000f1613a8a>] sock_sendmsg_nosec net/socket.c:652 [inline] [<00000000f1613a8a>] sock_sendmsg+0x4c/0x60 net/socket.c:672 Reported-and-tested-by: syzbot+b039f5699bd82e1fb011@xxxxxxxxxxxxxxxxxxxxxxxxx Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Pavel Skripkin <paskripkin@xxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/kcm/kcmsock.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1065,6 +1065,11 @@ out_error: goto partial_message; } + if (skb_has_frag_list(head)) { + kfree_skb_list(skb_shinfo(head)->frag_list); + skb_shinfo(head)->frag_list = NULL; + } + if (head != kcm->seq_skb) kfree_skb(head); Patches currently in stable-queue which might be from paskripkin@xxxxxxxxx are queue-4.9/net-kcm-fix-memory-leak-in-kcm_sendmsg.patch queue-4.9/net-caif-fix-memory-leak-in-cfusbl_device_notify.patch queue-4.9/net-caif-added-cfserl_release-function.patch queue-4.9/net-caif-add-proper-error-handling.patch queue-4.9/net-caif-fix-memory-leak-in-caif_device_notify.patch