From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3197AC433EF for ; Fri, 3 Jun 2022 17:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344117AbiFCRx3 (ORCPT ); Fri, 3 Jun 2022 13:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346910AbiFCRvn (ORCPT ); Fri, 3 Jun 2022 13:51:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC63C5A2D3; Fri, 3 Jun 2022 10:49:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 78694B823B0; Fri, 3 Jun 2022 17:49:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7596C385A9; Fri, 3 Jun 2022 17:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278581; bh=yIwoTYmHgD13KMGXjAlET+J3WJrNlVW7f/gtREit0J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SvxysiI9hT6hxFhB3/+LKTcMFZbW/3N5IygwGDxCmTp4Jx/B46CU/yAUVrSxo2YYM s21U21GQAnM36Pa+yFuTtwbpp6/aXvjTccr4Jay1M5eXmCHQ1F/rXnz1WRw5oIme8D 54nj5TujdYG2O1ZXkqRiecdW9Ra9L5k8ockAqZn8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 5.15 25/66] netfilter: nf_tables: hold mutex on netns pre_exit path Date: Fri, 3 Jun 2022 19:43:05 +0200 Message-Id: <20220603173821.385759263@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.663747061@linuxfoundation.org> References: <20220603173820.663747061@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pablo Neira Ayuso commit 3923b1e4406680d57da7e873da77b1683035d83f upstream. 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 Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -9746,7 +9746,11 @@ static int __net_init nf_tables_init_net static void __net_exit nf_tables_pre_exit_net(struct net *net) { + struct nftables_pernet *nft_net = nft_pernet(net); + + mutex_lock(&nft_net->commit_mutex); __nft_release_hooks(net); + mutex_unlock(&nft_net->commit_mutex); } static void __net_exit nf_tables_exit_net(struct net *net)