Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp103018iof; Sun, 5 Jun 2022 22:27:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwFEbt4KXSbD6yHHwm5tmcCSjAudeMAmWmNhvv7ou/sMsaRC5y0BqVxSTQMdkbNBTfqGWQ X-Received: by 2002:a17:90a:c981:b0:1e6:75f0:d4ea with SMTP id w1-20020a17090ac98100b001e675f0d4eamr26012191pjt.37.1654493277822; Sun, 05 Jun 2022 22:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654493277; cv=none; d=google.com; s=arc-20160816; b=ZVkUsvGq9O3eO6c8EHKg06m9kSZWE9RrUbiTRHunN3XJmb4FfazLB9MmLu2dr6iIz9 DhYaK2lGV+wuSFNicqXX5BR0CpaghLPUU83W2/M8NJXOCqHuEkUJIN4E49zuuDM+kJkc a4ZlT2ttLjieYrYafJyHwsAixTG7R2HqoketHkAsRd/N+TDzbM4xfM1F3u0gK8eEOe5q 2jG9H8+5hX6QKQ5Q7ySQ9VKogkG0Ti2lb7DQgaQkNrqqnjONTKJPOGT0MwywhKeO8gTZ /ROga96U1dCK+ANbw1Y5jYxvlJ6i8i7/6IwQjDV3CKghgtoBJedWeZXWf/ErU1xhhK9f 1FZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xIeppmnEcWo+A0SbcYZbfnatNFbHQjFxWQ5mdLB/QAU=; b=jJrURiu4WXsKnfb56vJPG7hO6vsUpXAkRrFgajXB36TwSi7lZte3k2QhPryUDgGMuO SZczRnV9PSgxV7wBw/B5FldKDz6dRCeGJJYIgeT42cnf+kdjD9Z80bhFpfVPX9EZff7D nIDdde3QZNch+ducyBnz/oRRy57ycpCpmhxvTjcX5tz7PujLUDQL/rcOwe2tMsCpQJmj bZb8xs5Ef4fba4qgK4GYRB4qtf5/OcTN9HwIfnVKQerx4jn0OJDNlSKrEASHcg3ePtU8 j5WiPxs6c9+mYWP9l5PCHm6mLF/fHU5E5VGMAOd+p9IRI8dKuCoEH5suq3hMcahF6iQl oFmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XjGD0uD4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o19-20020a170903211300b00163724c3d97si16081780ple.564.2022.06.05.22.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:27:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XjGD0uD4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E2EF1EB40C; Sun, 5 Jun 2022 21:29:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243870AbiFCSOK (ORCPT + 99 others); Fri, 3 Jun 2022 14:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346336AbiFCSAO (ORCPT ); Fri, 3 Jun 2022 14:00:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199E95838E; Fri, 3 Jun 2022 10:56:15 -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 B8F0EB82433; Fri, 3 Jun 2022 17:56:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1659DC385A9; Fri, 3 Jun 2022 17:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278972; bh=VPZI7tJahhauuvn30Lcv1xk+LwkmDvyMkCVb3evQetg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjGD0uD4QIA/ht9jVsuPsW/muVV0pyrufNa2tiH+n/BY2KZpu4CNdIYNJ8sVfSfUF mSKogDDbqpTJXjp0f3gLaK7CgAk802JrjQUaeU6aDJBFnJo8yjHdDhSYpxfsQ3KWhu fgMdLmAjOGJSpgO4xz/m1TlKO3/4mHf9Bg+DNfRk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 5.18 12/67] netfilter: nf_tables: hold mutex on netns pre_exit path Date: Fri, 3 Jun 2022 19:43:13 +0200 Message-Id: <20220603173821.084953001@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.731531504@linuxfoundation.org> References: <20220603173820.731531504@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -9892,7 +9892,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)