Netdev List
 help / color / mirror / Atom feed
From: Ren Wei <weir@nebusec.ai>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, willemb@google.com, horms@kernel.org,
	celston@katalix.com, jchapman@katalix.com,
	willemdebruijn.kernel@gmail.com, joe@dama.to, kuniyu@google.com,
	leitao@debian.org, jiayuan.chen@linux.dev, lirongqing@baidu.com,
	n0ps1edzz@gmail.com, vega@nebusec.ai, caoruide123@gmail.com,
	weir@nebusec.ai
Subject: [PATCH net 1/3] l2tp: revalidate IPv6 flowlabel after ancillary data
Date: Mon, 30 Nov 2026 11:02:20 +0800	[thread overview]
Message-ID: <01d770713a6fd42467f0d955a556149632bb9c4e.1795693858.git.caoruide123@gmail.com> (raw)
In-Reply-To: <cover.1795693858.git.caoruide123@gmail.com>

From: Ruide Cao <caoruide123@gmail.com>

l2tp_ip6_sendmsg() looks up the flowlabel named by
sockaddr_l2tpip6.l2tp_flowinfo before parsing ancillary data. An
IPV6_FLOWINFO cmsg can then replace fl6.flowlabel, but the ownership
lookup after ip6_datagram_send_ctl() is skipped when a flowlabel
reference is already held. A socket can therefore name a label it owns
in the sockaddr, override it with another socket's exclusive label in
the cmsg, and transmit the exclusive label, while fl6_merge_options()
still uses the options of the stale label.

Release the old reference when the final label differs from the one
already held, and look up the final label before transmission.

Fixes: a32e0eec7042 ("l2tp: introduce L2TPv3 IP encapsulation support for IPv6")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Signed-off-by: Ruide Cao <caoruide123@gmail.com>
Signed-off-by: Ren Wei <weir@nebusec.ai>
---
 net/l2tp/l2tp_ip6.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index bdaae1b64d25..be1fd51581bc 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -600,6 +600,11 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 			fl6_sock_release(flowlabel);
 			return err;
 		}
+		if (flowlabel &&
+		    flowlabel->label != (fl6.flowlabel & IPV6_FLOWLABEL_MASK)) {
+			fl6_sock_release(flowlabel);
+			flowlabel = NULL;
+		}
 		if ((fl6.flowlabel & IPV6_FLOWLABEL_MASK) && !flowlabel) {
 			flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
 			if (IS_ERR(flowlabel))
-- 
2.47.3


  reply	other threads:[~2026-11-30  3:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  3:02 [PATCH net 0/3] ipv6: validate flowlabel ownership after cmsg override Ren Wei
2026-11-30  3:02 ` Ren Wei [this message]
2026-11-30  3:02 ` [PATCH net 2/3] ipv6: udp: revalidate flowlabel after ancillary data Ren Wei
2026-11-30  3:02 ` [PATCH net 3/3] ipv6: raw: " Ren Wei
2026-11-30  3:09 ` [PATCH net 0/3] ipv6: validate flowlabel ownership after cmsg override netdev-bot+sinfo

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=01d770713a6fd42467f0d955a556149632bb9c4e.1795693858.git.caoruide123@gmail.com \
    --to=weir@nebusec.ai \
    --cc=caoruide123@gmail.com \
    --cc=celston@katalix.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jchapman@katalix.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=joe@dama.to \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=leitao@debian.org \
    --cc=lirongqing@baidu.com \
    --cc=n0ps1edzz@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vega@nebusec.ai \
    --cc=willemb@google.com \
    --cc=willemdebruijn.kernel@gmail.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