Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Hyunjung Ko <hj351016@gmail.com>
To: James Chapman <jchapman@katalix.com>, Jakub Kicinski <kuba@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Chris Elston <celston@katalix.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Hyunjung Ko <hj351016@gmail.com>
Subject: [PATCH net] l2tp: reject short IPv6 address attributes
Date: Tue, 17 Nov 2026 18:21:57 +0900	[thread overview]
Message-ID: <20261117092157.85513-1-hj351016@gmail.com> (raw)

L2TP_ATTR_IP6_SADDR and L2TP_ATTR_IP6_DADDR are NLA_BINARY with .len set
to sizeof(struct in6_addr), which only bounds the attribute from above.
l2tp_tunnel_sock_create() then copies a full in6_addr out of each one,
so a shorter attribute makes it read past the payload. If the attribute
is the last one in the message this picks up whatever lies behind the
skb tail (stale heap data unless init_on_alloc is set), which ends up
in the socket address and can be read back with L2TP_CMD_TUNNEL_GET.

The commands are GENL_UNS_ADMIN_PERM, so this is reachable from a user
namespace.

Require the exact length.

Fixes: f9bac8df908d ("l2tp: netlink api for l2tpv3 ipv6 unmanaged tunnels")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
---
 net/l2tp/l2tp_netlink.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 89ef04c78787..a07009d4cb00 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -910,14 +910,8 @@ static const struct nla_policy l2tp_nl_policy[L2TP_ATTR_MAX + 1] = {
 	[L2TP_ATTR_MTU]			= { .type = NLA_U16, },
 	[L2TP_ATTR_MRU]			= { .type = NLA_U16, },
 	[L2TP_ATTR_STATS]		= { .type = NLA_NESTED, },
-	[L2TP_ATTR_IP6_SADDR] = {
-		.type = NLA_BINARY,
-		.len = sizeof(struct in6_addr),
-	},
-	[L2TP_ATTR_IP6_DADDR] = {
-		.type = NLA_BINARY,
-		.len = sizeof(struct in6_addr),
-	},
+	[L2TP_ATTR_IP6_SADDR] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
+	[L2TP_ATTR_IP6_DADDR] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
 	[L2TP_ATTR_IFNAME] = {
 		.type = NLA_NUL_STRING,
 		.len = IFNAMSIZ - 1,
-- 
2.43.0


             reply	other threads:[~2026-11-17  9:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:21 Hyunjung Ko [this message]
2026-11-17  9:27 ` [PATCH net] l2tp: reject short IPv6 address attributes netdev-bot+sinfo
2026-11-17  9:34   ` khj

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=20261117092157.85513-1-hj351016@gmail.com \
    --to=hj351016@gmail.com \
    --cc=celston@katalix.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jchapman@katalix.com \
    --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