From: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>,
stable@vger.kernel.org
Subject: [PATCH] mpls: unregister sysctls before network device teardown
Date: Wed, 7 Oct 2026 20:12:37 +0000 [thread overview]
Message-ID: <20261007201237.171863-2-Jeremy.Jean@oss.cyber.gouv.fr> (raw)
On network namespace exit, loopback is freed before MPLS unregisters its
sysctls. A task can keep platform_labels open and write to it during exit.
The handler can then use the freed loopback device.
Unregister the sysctls in pre_exit.
Fixes: 7720c01f3f59 ("mpls: Add a sysctl to control the size of the mpls label table")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
net/mpls/af_mpls.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 17b78dc..ad4ad6f 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -2776,16 +2776,20 @@ static __net_init int mpls_net_init(struct net *net)
return 0;
}
-static __net_exit void mpls_net_exit(struct net *net)
+static __net_exit void mpls_net_pre_exit(struct net *net)
{
- struct mpls_route __rcu **platform_label;
- size_t platform_labels;
const struct ctl_table *table;
- unsigned int index;
table = net->mpls.ctl->ctl_table_arg;
unregister_net_sysctl_table(net->mpls.ctl);
kfree(table);
+}
+
+static __net_exit void mpls_net_exit(struct net *net)
+{
+ struct mpls_route __rcu **platform_label;
+ size_t platform_labels;
+ unsigned int index;
/* An rcu grace period has passed since there was a device in
* the network namespace (and thus the last in flight packet)
@@ -2816,6 +2820,7 @@ static __net_exit void mpls_net_exit(struct net *net)
static struct pernet_operations mpls_net_ops = {
.init = mpls_net_init,
+ .pre_exit = mpls_net_pre_exit,
.exit = mpls_net_exit,
};
--
2.47.3
next reply other threads:[~2026-10-07 20:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 20:12 Jérémy Jean [this message]
2026-10-07 20:18 ` [PATCH] mpls: unregister sysctls before network device teardown 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=20261007201237.171863-2-Jeremy.Jean@oss.cyber.gouv.fr \
--to=jeremy.jean@oss.cyber.gouv.fr \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--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