From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>,
Harald Welte <laforge@gnumonks.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Wojciech Drewek <wojciech.drewek@intel.com>,
osmocom-net-gprs@lists.osmocom.org, netdev@vger.kernel.org
Subject: [PATCH net] gtp: don't account echo responses to the ingress device
Date: Tue, 1 Dec 2026 17:08:14 +0900 [thread overview]
Message-ID: <179607412886.627476.9845250289077797086@gmail.com> (raw)
gtp0_send_echo_resp_ip() and gtp1u_send_echo_resp() turn the received
skb into the echo response and pass it to udp_tunnel_xmit_skb() with
skb->dev still set to the device the request arrived on. iptunnel_xmit()
then calls iptunnel_xmit_stats() on that device, which only handles
NETDEV_PCPU_STAT_TSTATS and NETDEV_PCPU_STAT_DSTATS. A request received
on lo, which has NETDEV_PCPU_STAT_LSTATS, hits the WARN_ON_ONCE() there:
WARNING: include/net/ip_tunnels.h:701 at iptunnel_xmit+0x646/0xb50
Call Trace:
<IRQ>
gtp_encap_recv+0x14ae/0x22e0
udp_queue_rcv_one_skb+0x60c/0xc50
udp_unicast_rcv_skb+0xc1/0x2c0
ip_protocol_deliver_rcu+0x1e6/0x360
ip_local_deliver_finish+0x35a/0x5b0
Before commit 8431c602f551 ("ip_tunnel: adapt iptunnel_xmit_stats() to
NETDEV_PCPU_STAT_DSTATS"), iptunnel_xmit_stats() updated dev->tstats of
the ingress device whatever stats type it had. On such kernels, such as
linux-6.1.y, a request received on lo writes 16 bytes past lo's per-CPU
pcpu_lstats.
The response is not traffic of the ingress device. Clear skb->dev before
sending it: iptunnel_xmit() skips the stats update for a NULL skb->dev,
and ip_output() takes the egress device from the route.
Fixes: 9af41cc33471 ("gtp: Implement GTP echo response")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. I sent it privately on 2026-11-18;
it comes to the list now because security-bugs.rst asks for bugs found
with AI assistance to be handled in public. The reproducer creates a
GTP device in its own user and network namespace and sends one GTP-U
echo request to 127.0.0.1:2152; it is available on request.
Reproduced on mainline v7.4-rc5 (fe6ff8d5d675); the patch is against
net (76fca30e8d34), and with it the reproducer runs clean.
drivers/net/gtp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 85d1b0c46ecf..f84a4f37e849 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -451,6 +451,7 @@ static int gtp0_send_echo_resp_ip(struct gtp_dev *gtp, struct sk_buff *skb)
return -1;
}
+ skb->dev = NULL;
udp_tunnel_xmit_skb(rt, gtp->sk0, skb,
fl4.saddr, fl4.daddr,
iph->tos,
@@ -714,6 +715,7 @@ static int gtp1u_send_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb)
return -1;
}
+ skb->dev = NULL;
udp_tunnel_xmit_skb(rt, gtp->sk1u, skb,
fl4.saddr, fl4.daddr,
iph->tos,
--
2.43.0
reply other threads:[~2026-12-01 8:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179607412886.627476.9845250289077797086@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=laforge@gnumonks.org \
--cc=netdev@vger.kernel.org \
--cc=osmocom-net-gprs@lists.osmocom.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=wojciech.drewek@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox