l2tp: reject short IPv6 address attributes
Subsystems (3)
PATCH 1/1 l2tp: reject short IPv6 address attributes
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.
--- net/l2tp/l2tp_netlink.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
net/l2tp/l2tp_netlink.c +2 -8
@@ -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,
Signature · 1 line
2.43.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
The issue was found by a static analysis scan (pattern rules for NLA_BINARY attributes that are read with a fixed size, LLM-assisted), then confirmed by reading the code.
It was triggered at runtime on 7.4-rc1 in QEMU: an unprivileged user in its own user+net namespace creates an L2TPv3 IPv6 tunnel with a 0 or 4 byte L2TP_ATTR_IP6_DADDR, and L2TP_CMD_TUNNEL_GET returns 16 bytes, the missing ones being stale heap data:
sent 0 byte(s): 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 sent 4 byte(s): 20 20 20 20 41 41 41 41 41 41 41 41 41 41 41 41
There is no KASAN report, since the read stays inside the skb head allocation. The leaked bytes are non-zero only with init_on_alloc=0.
2026년 11월 17일 (화) 오후 6:27, <[email protected]>님이 작성:
Quoted 23 lines
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. --
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Quoted 44 lines · Hyunjung Ko
L2TP_ATTR_IP6_SADDRandL2TP_ATTR_IP6_DADDRareNLA_BINARYwith .len set tosizeof(struct in6_addr), which only bounds the attribute from above.l2tp_tunnel_sock_create()then copies a fullin6_addrout 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 unlessinit_on_allocis set), which ends up in the socket address and can be read back withL2TP_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")Signed-off-by Hyunjung Ko <[email protected]>--- net/l2tp/l2tp_netlink.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)net/l2tp/l2tp_netlink.c +2
-8@@ -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,Signature · 1 line
2.43.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 17 Nov 2026 18:21:57 +0900 you wrote:
L2TP_ATTR_IP6_SADDRandL2TP_ATTR_IP6_DADDRareNLA_BINARYwith .len set tosizeof(struct in6_addr), which only bounds the attribute from above.l2tp_tunnel_sock_create()then copies a fullin6_addrout 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 unlessinit_on_allocis set), which ends up in the socket address and can be read back withL2TP_CMD_TUNNEL_GET.[...]
Here is the summary with links:
- [net] l2tp: reject short IPv6 address attributes
https://git.kernel.org/netdev/net/c/3bf0ed569563
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html