Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [STABLE] Backport requests for net/crypto fixes
@ 2026-05-07  6:07 Yuan Tan
  2026-05-07  9:22 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Yuan Tan @ 2026-05-07  6:07 UTC (permalink / raw)
  To: stable; +Cc: yuantan098

[STABLE] Backport requests for net/crypto fixes

Hi Linux stable team,

Please consider backporting the following 3 upstream bug fixing commits to
the relevant stable trees. After my inspection, they have not been
backported.

I am grouping these requests together for convenience. If you would prefer
that I send one backport request per email, please let me know. 

MAINLINE_COMMIT                               MERGED_TO_MAINLINE_AT         TITLE
629ec78ef8608d955ce217880cdc3e1873af3a15    2026-04-02T09:57:06-07:00    mpls: add seqcount to protect the platform_label{,s} pair
426c355742f02cf743b347d9d7dbdc1bfbfa31ef    2026-04-09T08:39:25-07:00    net: af_key: zero aligned sockaddr tail in PF_KEY exports
01d798e9feb30212952d4e992801ba6bd6a82351    2026-04-15T15:22:26-07:00    crypto: jitterentropy - replace long-held spinlock with mutex

Please let me know if you need any further information.

Thanks,
Yuan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [STABLE] Backport requests for net/crypto fixes
  2026-05-07  6:07 [STABLE] Backport requests for net/crypto fixes Yuan Tan
@ 2026-05-07  9:22 ` Greg KH
  2026-05-09  0:26   ` Yuan Tan
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2026-05-07  9:22 UTC (permalink / raw)
  To: Yuan Tan; +Cc: stable

On Wed, May 06, 2026 at 11:07:50PM -0700, Yuan Tan wrote:
> [STABLE] Backport requests for net/crypto fixes
> 
> Hi Linux stable team,
> 
> Please consider backporting the following 3 upstream bug fixing commits to
> the relevant stable trees. After my inspection, they have not been
> backported.
> 
> I am grouping these requests together for convenience. If you would prefer
> that I send one backport request per email, please let me know. 
> 
> MAINLINE_COMMIT                               MERGED_TO_MAINLINE_AT         TITLE
> 629ec78ef8608d955ce217880cdc3e1873af3a15    2026-04-02T09:57:06-07:00    mpls: add seqcount to protect the platform_label{,s} pair
> 426c355742f02cf743b347d9d7dbdc1bfbfa31ef    2026-04-09T08:39:25-07:00    net: af_key: zero aligned sockaddr tail in PF_KEY exports

These both are in stable releases, what specific tree(s) do you want it
in?

> 01d798e9feb30212952d4e992801ba6bd6a82351    2026-04-15T15:22:26-07:00    crypto: jitterentropy - replace long-held spinlock with mutex

What kernel tree(s) do you want this in?  Why was this not tagged for
stable already?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [STABLE] Backport requests for net/crypto fixes
  2026-05-07  9:22 ` Greg KH
@ 2026-05-09  0:26   ` Yuan Tan
  2026-05-09 14:32     ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Yuan Tan @ 2026-05-09  0:26 UTC (permalink / raw)
  To: Greg KH; +Cc: stable

On Thu, May 7, 2026 at 2:23 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, May 06, 2026 at 11:07:50PM -0700, Yuan Tan wrote:
> > [STABLE] Backport requests for net/crypto fixes
> >
> > Hi Linux stable team,
> >
> > Please consider backporting the following 3 upstream bug fixing commits to
> > the relevant stable trees. After my inspection, they have not been
> > backported.
> >
> > I am grouping these requests together for convenience. If you would prefer
> > that I send one backport request per email, please let me know.
> >
> > MAINLINE_COMMIT                               MERGED_TO_MAINLINE_AT         TITLE
> > 629ec78ef8608d955ce217880cdc3e1873af3a15    2026-04-02T09:57:06-07:00    mpls: add seqcount to protect the platform_label{,s} pair
> > 426c355742f02cf743b347d9d7dbdc1bfbfa31ef    2026-04-09T08:39:25-07:00    net: af_key: zero aligned sockaddr tail in PF_KEY exports
>
> These both are in stable releases, what specific tree(s) do you want it
> in?

Regarding "mpls: add seqcount to protect the platform_label{,s} pair":
Both 6.12.y and 6.18.y are affected. However, our testing shows that
backporting results in code conflicts. We can send the resolved
patches later.

Regarding "net: af_key: zero aligned sockaddr tail in PF_KEY exports":
Our testing shows that the mainline patch can be backported to 6.12.y
and 6.18.y cleanly without any conflicts.

>
> > 01d798e9feb30212952d4e992801ba6bd6a82351    2026-04-15T15:22:26-07:00    crypto: jitterentropy - replace long-held spinlock with mutex
>
> What kernel tree(s) do you want this in?  Why was this not tagged for
> stable already?

We have re-evaluated this bug and concluded that it requires root
privileges to trigger and has no security impact. Therefore, it does
not need to be backported.

Apologies for the confusion; we will improve our process next time.

>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [STABLE] Backport requests for net/crypto fixes
  2026-05-09  0:26   ` Yuan Tan
@ 2026-05-09 14:32     ` Sasha Levin
  2026-11-25 19:22       ` [PATCH 6.18.y] mpls: add seqcount to protect the platform_label{,s} pair Artem Dinaburg
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2026-05-09 14:32 UTC (permalink / raw)
  To: Greg KH; +Cc: Sasha Levin, stable, Yuan Tan

> 2) 426c355742f0 ("net: af_key: zero aligned sockaddr tail in PF_KEY
>    exports") - targets 6.12.y and 6.18.y; cherry-pick is clean.

Queued for 6.12.y and 6.18.y, thanks.

> 1) 629ec78ef860 (mpls seqcount) - cherry-pick conflicts on 6.12/6.18;
>    I'll send manually-resolved patches later.

Sounds good, will look out for the resolved versions.

--
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 6.18.y] mpls: add seqcount to protect the platform_label{,s} pair
  2026-05-09 14:32     ` Sasha Levin
@ 2026-11-25 19:22       ` Artem Dinaburg
  2026-11-27 17:00         ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Artem Dinaburg @ 2026-11-25 19:22 UTC (permalink / raw)
  To: stable
  Cc: bird, davem, edumazet, horms, kuba, netdev, pabeni, sd, tanyuan98,
	tomapufckgml, yifanwucs

From: Sabrina Dubroca <sd@queasysnail.net>
Date: Tue, 24 Mar 2026 00:25:57 +0100

[ Upstream commit 629ec78ef8608d955ce217880cdc3e1873af3a15 ]

The RCU-protected codepaths (mpls_forward, mpls_dump_routes) can have
an inconsistent view of platform_labels vs platform_label in case of a
concurrent resize (resize_platform_label_table, under
platform_mutex). This can lead to OOB accesses.

This patch adds a seqcount, so that we get a consistent snapshot.

Note that mpls_label_ok is also susceptible to this, so the check
against RTA_DST in rtm_to_route_config, done outside platform_mutex,
is not sufficient. This value gets passed to mpls_label_ok once more
in both mpls_route_add and mpls_route_del, so there is no issue, but
that additional check must not be removed.

Reported-by: Yuan Tan <tanyuan98@outlook.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Fixes: 7720c01f3f590 ("mpls: Add a sysctl to control the size of the mpls label table")
Fixes: dde1b38e873c ("mpls: Convert mpls_dump_routes() to RCU.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/cd8fca15e3eb7e212b094064cd83652e20fd9d31.1774284088.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

[ Backport to 6.18.y: 6.18.y has neither the per-netns platform_mutex
  (upstream e833eb25161a) nor the RCU conversion of mpls_dump_routes()
  (upstream dde1b38e873c); resize_platform_label_table() is serialized
  by RTNL. Use a plain seqcount_t instead of seqcount_mutex_t and
  disable preemption explicitly around the write section, since
  local_bh_disable() does not do so on PREEMPT_RT. Keep
  rcu_dereference_rtnl() in the helper because mpls_getroute() reaches
  it under RTNL without rcu_read_lock(). mpls_dump_routes() still runs
  under RTNL, so it is left unchanged. ]
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
---
Hi,

Yuan Tan offered resolved versions of upstream 629ec78ef860 in this
thread in May. I have not seen one posted for 6.18.y, so I am offering
this one.

The fix is in 6.1.191, 6.6.160, 6.12.114 and 6.19.12, and in mainline
since 7.0. The upstream commit does not apply to 6.18.y; the backport
note above lists the differences.

6.12.y took the upstream fix together with its prerequisites
dde1b38e873c ("mpls: Convert mpls_dump_routes() to RCU.") and
e833eb25161a ("mpls: Protect net->mpls.platform_label with a per-netns
mutex."). On 6.18.y, e833eb25161a does not apply either, so that route
would need at least one more adapted patch. This patch is the smaller
change: it follows the 6.6.160 backport and keeps RTNL as the writer
lock, adding only explicit preemption disabling for PREEMPT_RT.

Compiled net/mpls/af_mpls.o with CONFIG_WERROR=y on 6.18.65 from a
cumulative x86_64 tree, with and without the current queue-6.18 patches.
No kernel boot or runtime test was performed. PREEMPT_RT was not built.

An LLM was used to prepare this backport and to check applicability and
stable-queue history; I reviewed the result.

Thanks,
Artem Dinaburg

 include/net/netns/mpls.h |  2 ++
 net/mpls/af_mpls.c       | 37 ++++++++++++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/include/net/netns/mpls.h b/include/net/netns/mpls.h
index 19ad2574b267..9b83b7f43d83 100644
--- a/include/net/netns/mpls.h
+++ b/include/net/netns/mpls.h
@@ -7,6 +7,7 @@
 #define __NETNS_MPLS_H__
 
 #include <linux/types.h>
+#include <linux/seqlock.h>
 
 struct mpls_route;
 struct ctl_table_header;
@@ -16,6 +17,7 @@ struct netns_mpls {
 	int default_ttl;
 	size_t platform_labels;
 	struct mpls_route __rcu * __rcu *platform_label;
+	seqcount_t platform_label_seq;
 
 	struct ctl_table_header *ctl;
 };
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 608c43a4602d..9ed136931c4f 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -75,16 +75,31 @@ static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
 		       struct nlmsghdr *nlh, struct net *net, u32 portid,
 		       unsigned int nlm_flags);
 
+static struct mpls_route __rcu **mpls_platform_label_rcu(struct net *net, size_t *platform_labels)
+{
+	struct mpls_route __rcu **platform_label;
+	unsigned int sequence;
+
+	do {
+		sequence = read_seqcount_begin(&net->mpls.platform_label_seq);
+		platform_label = rcu_dereference_rtnl(net->mpls.platform_label);
+		*platform_labels = net->mpls.platform_labels;
+	} while (read_seqcount_retry(&net->mpls.platform_label_seq, sequence));
+
+	return platform_label;
+}
+
 static struct mpls_route *mpls_route_input_rcu(struct net *net, unsigned index)
 {
-	struct mpls_route *rt = NULL;
+	struct mpls_route __rcu **platform_label;
+	size_t platform_labels;
 
-	if (index < net->mpls.platform_labels) {
-		struct mpls_route __rcu **platform_label =
-			rcu_dereference_rtnl(net->mpls.platform_label);
-		rt = rcu_dereference_rtnl(platform_label[index]);
-	}
-	return rt;
+	platform_label = mpls_platform_label_rcu(net, &platform_labels);
+
+	if (index >= platform_labels)
+		return NULL;
+
+	return rcu_dereference_rtnl(platform_label[index]);
 }
 
 bool mpls_output_possible(const struct net_device *dev)
@@ -2582,8 +2597,14 @@ static int resize_platform_label_table(struct net *net, size_t limit)
 	}
 
 	/* Update the global pointers */
+	local_bh_disable();
+	preempt_disable();
+	write_seqcount_begin(&net->mpls.platform_label_seq);
 	net->mpls.platform_labels = limit;
 	rcu_assign_pointer(net->mpls.platform_label, labels);
+	write_seqcount_end(&net->mpls.platform_label_seq);
+	preempt_enable();
+	local_bh_enable();
 
 	rtnl_unlock();
 
@@ -2664,6 +2685,8 @@ static int mpls_net_init(struct net *net)
 	struct ctl_table *table;
 	int i;
 
+	seqcount_init(&net->mpls.platform_label_seq);
+
 	net->mpls.platform_labels = 0;
 	net->mpls.platform_label = NULL;
 	net->mpls.ip_ttl_propagate = 1;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 6.18.y] mpls: add seqcount to protect the platform_label{,s} pair
  2026-11-25 19:22       ` [PATCH 6.18.y] mpls: add seqcount to protect the platform_label{,s} pair Artem Dinaburg
@ 2026-11-27 17:00         ` Sasha Levin
  0 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2026-11-27 17:00 UTC (permalink / raw)
  To: stable
  Cc: Sasha Levin, bird, davem, edumazet, horms, kuba, netdev, pabeni,
	sd, tanyuan98, tomapufckgml, yifanwucs, Artem Dinaburg

> The RCU-protected codepaths (mpls_forward, mpls_dump_routes) can have
> an inconsistent view of platform_labels vs platform_label in case of a
> concurrent resize (resize_platform_label_table, under
> platform_mutex). This can lead to OOB accesses.

Queued for 6.18, thanks.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-27 17:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07  6:07 [STABLE] Backport requests for net/crypto fixes Yuan Tan
2026-05-07  9:22 ` Greg KH
2026-05-09  0:26   ` Yuan Tan
2026-05-09 14:32     ` Sasha Levin
2026-11-25 19:22       ` [PATCH 6.18.y] mpls: add seqcount to protect the platform_label{,s} pair Artem Dinaburg
2026-11-27 17:00         ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox