From: Hui Peng <benquike@gmail.com>
To: Andrea Mayer <andrea.mayer@uniroma2.it>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ipv6: sr: fix 16-byte kernel heap leak in seg6_genl_set_tunsrc()
Date: Sat, 19 Sep 2026 20:48:06 +0000 [thread overview]
Message-ID: <20260919204807.2812472-1-benquike@gmail.com> (raw)
seg6_genl_policy[SEG6_ATTR_DST] uses NLA_BINARY with
.len = sizeof(struct in6_addr), which only caps the maximum attribute
length and allows 0-byte SEG6_ATTR_DST attributes.
seg6_genl_set_tunsrc() then unconditionally copies
sizeof(struct in6_addr) (16 bytes) from
nla_data(info->attrs[SEG6_ATTR_DST]) into sdata->tun_src via kmemdup(),
reading 16 bytes of uninitialized skb->head heap memory past skb->tail
and exposing it to userspace via SEG6_CMD_GET_TUNSRC.
Enforce NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)) in
seg6_genl_policy and validate nla_len(info->attrs[SEG6_ATTR_DST]) in
seg6_genl_set_tunsrc().
Fixes: 915d7e5e5930 ("ipv6: sr: add code base for control plane support of SR-IPv6")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -138,8 +138,8 @@ out:
static struct genl_family seg6_genl_family;
static const struct nla_policy seg6_genl_policy[SEG6_ATTR_MAX + 1] = {
- [SEG6_ATTR_DST] = { .type = NLA_BINARY,
- .len = sizeof(struct in6_addr) },
+ [SEG6_ATTR_DST] =
+ NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
[SEG6_ATTR_DSTLEN] = { .type = NLA_S32, },
[SEG6_ATTR_HMACKEYID] = { .type = NLA_U32, },
[SEG6_ATTR_SECRET] = { .type = NLA_BINARY, },
@@ -242,7 +242,8 @@ static int seg6_genl_set_tunsrc(struct sk_buff *skb, struct genl_info *info)
sdata = seg6_pernet(net);
- if (!info->attrs[SEG6_ATTR_DST])
+ if (!info->attrs[SEG6_ATTR_DST] ||
+ nla_len(info->attrs[SEG6_ATTR_DST]) != sizeof(struct in6_addr))
return -EINVAL;
val = nla_data(info->attrs[SEG6_ATTR_DST]);
--
2.43.0
next reply other threads:[~2026-09-19 20:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 20:48 Hui Peng [this message]
2026-09-20 7:01 ` Hangbin Liu
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=20260919204807.2812472-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®