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 2/3] ipv6: udp: revalidate flowlabel after ancillary data
Date: Mon, 30 Nov 2026 11:02:21 +0800	[thread overview]
Message-ID: <9aaca54ab8555a48300d2847a02520694fd4bcbc.1795693858.git.caoruide123@gmail.com> (raw)
In-Reply-To: <cover.1795693858.git.caoruide123@gmail.com>

From: Ruide Cao <caoruide123@gmail.com>

udpv6_sendmsg() looks up the flowlabel named by sin6_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. An unprivileged
UDP socket can therefore name a label it owns in sin6_flowinfo,
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. A cmsg
that keeps the same label, or a connected socket's default label
overridden by an owned label, behaves as before.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
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/ipv6/udp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index a6886a0432f9..f23e7ed2a47b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1631,6 +1631,11 @@ int udpv6_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


  parent 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 ` [PATCH net 1/3] l2tp: revalidate IPv6 flowlabel after ancillary data Ren Wei
2026-11-30  3:02 ` Ren Wei [this message]
2026-11-30  3:02 ` [PATCH net 3/3] ipv6: raw: revalidate " 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=9aaca54ab8555a48300d2847a02520694fd4bcbc.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