From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388678; b=SO6LZOKyrUlkGB0cC9Savc8WsWMxgHvZp86fJDjNmON0W2WJryBWoU0AjiU/5NdPonwf qnSHMgunSWG9G2K56uRnOU525RPm4nAEo/+IaVIHYiyePB/+65I9g9vEWm+XHmoRAgtf0 Uqt2HdbNDmUjxZXorjMxPffkT7pITrcSz7qc2ELfj/JfZnUYCXJMoh5Aa5O633C7kQrE3 JJMuWj+ta+PZaeSkVBYfYTTBFd8u21oj7fm98LpCzEYFgvHsdoJvshe2goaoR/+vbxjZs LjvTlGDMKE37znE516JY0oi48dGOPrncAihimY+8qZEbpGHaLWpRZcevaIHJdm9NtTA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388678; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=H/nVlbjFUn7yeq2/8+2M/wwLtX9+X3Cx4GCA5p9VlY4=; b=R7DHtS7mVXHN6uAJLHC7YFZ4AMJiD4KEbofJR9zDVJa1Lf3tN/BOMHZqQkvlc41jf7RI frqrIoF9K42IoA5dl8O/hhwOOC9LM60S/2LguyRkCD09rGfLpVZxt11fhRki5MuxkP8U9 /XZ725dFWbYjUqyEucTaGktBVH1v3R1jbfc/TML9REq/djfDEQ7GrQqDnEeWb0D24qM82 FNRzymdCEqvCmXMLzX/lEVcMKkv1aQR+vacvEsnVobvLyY40lCkSPMXFy9XtzWmh6BM9g CyLDnCtwdWLmy3T0JeHYbRjm/ZFfJ/gs/8HsSVTr+pJFFH2e9312EDNKYRnfQ1KqcyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ZyTFVzjf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A8AE606A32C; Fri, 4 Dec 2026 12:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ZyTFVzjf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36F8C1F000C2; Fri, 4 Dec 2026 12:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388677; bh=H/nVlbjFUn7yeq2/8+2M/wwLtX9+X3Cx4GCA5p9VlY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZyTFVzjfjUcEvMR2BZm2NmE7Ox/95QB50LwnUV0TpJ7Q79bB3dYKtOIcb3A2Szx2+ LQeWJdThCOqhllMMH9GJXP8ofvfG0gzkRYNT4fTpXdUnEnNgzayEO2+Y30w+lDhHE2 /CwnHovEsms45eNb5ZGQuIyPKES5N+3mLu/BeJNY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0709/1059] gtp: free the skb after handling an echo response Date: Fri, 4 Dec 2026 19:04:00 +0900 Message-ID: <20261204100702.341509316@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos [ Upstream commit f17b293d155f377e4cff582b8113991d2ad346d6 ] gtp0_handle_echo_resp() and gtp1u_handle_echo_resp() return the result of genlmsg_multicast_netns() to gtp_encap_recv(). When the netlink notification is delivered that result is 0, and gtp_encap_recv() treats 0 as "the skb has been consumed": switch (ret) { case 1: netdev_dbg(gtp->dev, "pass up to the process\n"); break; case 0: break; case -1: netdev_dbg(gtp->dev, "GTP packet has been dropped\n"); kfree_skb(skb); ret = 0; break; } The echo response handlers only read from the skb and never free it or pass it on, so every echo response that is reported to a listener on the gtp multicast group leaks the skb. Echo responses are handled for any peer when the UDP sockets were created by the kernel, so a remote host can leak memory on the receiver by sending GTP echo responses while a process with CAP_NET_ADMIN is subscribed to the gtp multicast group, for example a daemon that monitors echo responses. The error paths do not leak but have a related problem. -ENOMEM and the error from genlmsg_multicast_netns() (-ESRCH when nobody listens) are not -1, so they are returned unchanged to the UDP stack, which takes a negative value from encap_rcv() as a request to resubmit the packet to the protocol with that number. Return -1 when the notification cannot be built, so that gtp_encap_recv() drops the skb, and consume the skb once the notification has been handed to netlink, whether or not anybody is listening. Found by LLM-assisted source review, untested. Fixes: d33bd757d362 ("gtp: Implement GTP echo request") Cc: stable@vger.kernel.org Signed-off-by: Joas Antonio dos Santos Link: https://patch.msgid.link/20261110-gtp-echo-rsp-leak-v1-1-192c032f3dfa@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/gtp.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 94f4be527e539..841cd3220c2bd 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -396,16 +396,19 @@ static int gtp0_handle_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb) msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!msg) - return -ENOMEM; + return -1; ret = gtp_genl_fill_echo(msg, 0, 0, 0, GTP_CMD_ECHOREQ, echo); if (ret < 0) { nlmsg_free(msg); - return ret; + return -1; } - return genlmsg_multicast_netns(>p_genl_family, dev_net(gtp->dev), - msg, 0, GTP_GENL_MCGRP, GFP_ATOMIC); + genlmsg_multicast_netns(>p_genl_family, dev_net(gtp->dev), + msg, 0, GTP_GENL_MCGRP, GFP_ATOMIC); + consume_skb(skb); + + return 0; } /* 1 means pass up to the stack, -1 means drop and 0 means decapsulated. */ @@ -560,16 +563,19 @@ static int gtp1u_handle_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb) msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!msg) - return -ENOMEM; + return -1; ret = gtp_genl_fill_echo(msg, 0, 0, 0, GTP_CMD_ECHOREQ, echo); if (ret < 0) { nlmsg_free(msg); - return ret; + return -1; } - return genlmsg_multicast_netns(>p_genl_family, dev_net(gtp->dev), - msg, 0, GTP_GENL_MCGRP, GFP_ATOMIC); + genlmsg_multicast_netns(>p_genl_family, dev_net(gtp->dev), + msg, 0, GTP_GENL_MCGRP, GFP_ATOMIC); + consume_skb(skb); + + return 0; } static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) -- 2.53.0