From: Hangbin Liu <hangbin.liu@linux.dev>
To: Hyunjung Ko <hj351016@gmail.com>
Cc: James Chapman <jchapman@katalix.com>,
Jakub Kicinski <kuba@kernel.org>,
"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
Subject: Re: [PATCH net] l2tp: reject short IPv6 address attributes
Date: Wed, 18 Nov 2026 09:50:55 +0800 [thread overview]
Message-ID: <av0EfxJlYXo2XbU-@fedora> (raw)
In-Reply-To: <20261117092157.85513-1-hj351016@gmail.com>
On Tue, Nov 17, 2026 at 06:21:57PM +0900, Hyunjung Ko wrote:
> 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
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
prev parent reply other threads:[~2026-11-18 1:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:21 [PATCH net] l2tp: reject short IPv6 address attributes Hyunjung Ko
2026-11-17 9:27 ` netdev-bot+sinfo
2026-11-17 9:34 ` khj
2026-11-18 1:50 ` Hangbin Liu [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=av0EfxJlYXo2XbU-@fedora \
--to=hangbin.liu@linux.dev \
--cc=celston@katalix.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hj351016@gmail.com \
--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