From: Ido Schimmel <idosch@nvidia.com>
To: Henry Martin <bsdhenrymartin@gmail.com>
Cc: David Ahern <dsahern@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net] ip6mr: prevent info-leak in ip6mr_cache_report()
Date: Mon, 16 Nov 2026 18:40:18 +0200 [thread overview]
Message-ID: <20261116164018.GA422990@shredder> (raw)
In-Reply-To: <20261112042415.617221-1-bsdhenrymartin@gmail.com>
On Thu, Nov 12, 2026 at 12:24:15PM +0800, Henry Martin wrote:
> The non-WHOLEPKT branch copies the IPv6 header at offset 0 and then
> appends 40 bytes with skb_put(), but the mrt6msg is written at offset 0
> after skb_reset_transport_header(), so the appended 40 bytes are never
> initialized. They hold stale heap contents.
>
> The report is queued to the mroute6 socket and copied into the
> IP6MRA_CREPORT_PKT netlink attribute, disclosing the stale bytes to
> user space. The stale bytes can contain kernel heap and image
> pointers, and the report is reachable from an unprivileged user
> namespace (MRT6_INIT in a new netns, plus the non-root
> RTNLGRP_IPV6_MROUTE_R group).
>
> Use skb_put_zero() instead, as the IPv4 code does since
> commit 4f34002e2e376 ("ipmr: prevent info-leak in pmr_cache_report()").
>
> This issue was discovered by Tencent CodeBuddy Security.
>
> Fixes: 7bc570c8b4f75 ("[IPV6] MROUTE: Support multicast forwarding.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Note that:
1. You're expected to answer to the bot with the requested information.
2. Better, avoid getting your patch flagged by the bot in the first
place by putting the relevant information (a KMSAN trace in this case)
in the commit message. See commit aa1799e93f5e ("ipmr, ip6mr: validate
packets injected into the register vif on xmit"), for example.
Anyway, this code is quite bizarre. Unclear why it allocates room for 80
bytes, writes the IPv6 header to the first 40, then overwrites it with
'mrt6msg' and leaves the remaining 40 bytes as garbage.
I will follow up with the following diff after your patch is in
net-next:
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index b7ae220d6b21..31f0e1ef5601 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1107,7 +1107,7 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt,
+sizeof(*msg));
else
#endif
- skb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(*msg), GFP_ATOMIC);
+ skb = alloc_skb(sizeof(*msg), GFP_ATOMIC);
if (!skb)
return -ENOBUFS;
@@ -1143,20 +1143,9 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt,
} else
#endif
{
- /*
- * Copy the IP header
- */
-
- skb_put(skb, sizeof(struct ipv6hdr));
+ msg = skb_put(skb, sizeof(*msg));
skb_reset_network_header(skb);
- skb_copy_to_linear_data(skb, ipv6_hdr(pkt), sizeof(struct ipv6hdr));
-
- /*
- * Add our header
- */
- skb_put_zero(skb, sizeof(*msg));
skb_reset_transport_header(skb);
- msg = (struct mrt6msg *)skb_transport_header(skb);
msg->im6_mbz = 0;
msg->im6_msgtype = assert;
prev parent reply other threads:[~2026-11-16 16:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 4:24 Henry Martin
2026-11-12 4:31 ` netdev-bot+sinfo
2026-11-16 16:40 ` Ido Schimmel [this message]
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=20261116164018.GA422990@shredder \
--to=idosch@nvidia.com \
--cc=bsdhenrymartin@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®