netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: stable@vger.kernel.org, carnil@debian.org
Subject: [PATCH -stable,5.10 3/3] netfilter: nf_tables: hold mutex on netns pre_exit path
Date: Mon, 26 Jun 2023 13:05:06 +0200	[thread overview]
Message-ID: <20230626110506.76630-4-pablo@netfilter.org> (raw)
In-Reply-To: <20230626110506.76630-1-pablo@netfilter.org>

[ 3923b1e4406680d57da7e873da77b1683035d83f ]

clean_net() runs in workqueue while walking over the lists, grab mutex.

Fixes: 767d1216bff8 ("netfilter: nftables: fix possible UAF over chains from packet path in netns")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 0b2a6f988e9b..f5607d4359bb 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -8980,7 +8980,9 @@ static int __net_init nf_tables_init_net(struct net *net)
 
 static void __net_exit nf_tables_pre_exit_net(struct net *net)
 {
+	mutex_lock(&net->nft.commit_mutex);
 	__nft_release_hooks(net);
+	mutex_unlock(&net->nft.commit_mutex);
 }
 
 static void __net_exit nf_tables_exit_net(struct net *net)
-- 
2.30.2


  parent reply	other threads:[~2023-06-26 11:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 11:05 [PATCH -stable,5.10 0/3] stable fixes for 5.10 Pablo Neira Ayuso
2023-06-26 11:05 ` [PATCH -stable,5.10 1/3] netfilter: nftables: statify nft_parse_register() Pablo Neira Ayuso
2023-06-26 11:05 ` [PATCH -stable,5.10 2/3] netfilter: nf_tables: validate registers coming from userspace Pablo Neira Ayuso
2023-06-26 11:05 ` Pablo Neira Ayuso [this message]
2023-06-26 15:27 ` [PATCH -stable,5.10 0/3] stable fixes for 5.10 Greg KH

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=20230626110506.76630-4-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=carnil@debian.org \
    --cc=netfilter-devel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).