Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3082893rwe; Mon, 29 Aug 2022 05:39:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR5LqyQrA8dDu37Vl9Le8kQGdxfOSH6CxQhRo4urYDH6/5MUHZKvmHi04RtQm+Gstkv7z47t X-Received: by 2002:a17:902:d50b:b0:172:d4f4:91aa with SMTP id b11-20020a170902d50b00b00172d4f491aamr16922750plg.53.1661776783803; Mon, 29 Aug 2022 05:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661776783; cv=none; d=google.com; s=arc-20160816; b=Ch1g6nBhccZmzZ1sFfomdFGxFVWD8we+EitKhWziih08VkS81IIxWE6C2kaMZMGk4m zTdYIl2zOQ7cD/C01JN1v1Xb4fF/StlmCnHW7VK9efz3yyNaUH572f+8I3AZYT/WPHap 6hHdd3unakv+m8Ze3aDY866W6mUHeAyDXIflGNYrUg31cwwjqj6Fu/Ee9l3P9+H7EW7Q R0hB03McuOxO1u8xHRprt6vZqzwJBfiKQwBqiCNrCUmBGKbD0IAkhSM/7vErde0XsqXa jopDIpiRGD4ax4a1++I8QozaPdXq0Y2/8Iyku4FtHDoqDzn1yaaVi/Be1ZKVQWnryzsn TyKw== 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=4nQ1Hhu3EBDCf4Hsr2/VIdsON3Y9NGHAtfZ2AP/Ieow=; b=OTEd+75LqXnIPtUtlafs05VHqPdTwB0HM+v1DFy1J2bzA9GSPjHueWzbOjmndoGPaT riAnF896qMU6EJ+uYb+CicA9r8EZZMGvbaRSA0wxTgXaBxZUTBieM2KmvmZH0B5qo8hN cAYyihMaXg7qnPpoLO9UJnqQDW1G2ytJDS0UoMMdAS2EX0XqT9WVeEFfE5s84blf3yRb M+3aZWH7QyBhI5fpdCjF/B2hvAlsm3vCocre+DTGm21tnKs5xM4kkYiYWwW0L3lq/PbV wH/oBQEaBPmUi+wyW4Eqxj32b2Dacs2wG7fJu1lM5jW2XSk2P9W/QMm4uUhnmiz84U6s ocSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aMbwW87P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a63590e000000b004298268026fsi8587147pgb.142.2022.08.29.05.39.32; Mon, 29 Aug 2022 05:39:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aMbwW87P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbiH2LYq (ORCPT + 99 others); Mon, 29 Aug 2022 07:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231820AbiH2LWl (ORCPT ); Mon, 29 Aug 2022 07:22:41 -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 A96B675FC0; Mon, 29 Aug 2022 04:14:19 -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 322C9B80F9A; Mon, 29 Aug 2022 11:14:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96D2EC433D6; Mon, 29 Aug 2022 11:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771651; bh=nYi7yo5WilhPU9ch9G1UIw/5uXKbivK+derF2TVJPiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMbwW87Pfvtts8RxSaRaZzqQWNyaE6N/9ScFFwtu5kpZgVnraxjBM20bZx9ECkmKx hU/4/AJAed67ChrpWmKQ/JaBPxedeZvqpnmX8dfesvRFr0rgvXDc25+5coeDBycw8v tWFycOOlUqWZEgcVb2yHqXNSTOsFHnU735xoYn0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abhishek Shah , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.19 056/158] netfilter: nf_tables: make table handle allocation per-netns friendly Date: Mon, 29 Aug 2022 12:58:26 +0200 Message-Id: <20220829105811.071559791@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 [ Upstream commit ab482c6b66a4a8c0a8c0b0f577a785cf9ff1c2e2 ] mutex is per-netns, move table_netns to the pernet area. *read-write* to 0xffffffff883a01e8 of 8 bytes by task 6542 on cpu 0: nf_tables_newtable+0x6dc/0xc00 net/netfilter/nf_tables_api.c:1221 nfnetlink_rcv_batch net/netfilter/nfnetlink.c:513 [inline] nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:634 [inline] nfnetlink_rcv+0xa6a/0x13a0 net/netfilter/nfnetlink.c:652 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x652/0x730 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x643/0x740 net/netlink/af_netlink.c:1921 Fixes: f102d66b335a ("netfilter: nf_tables: use dedicated mutex to guard transactions") Reported-by: Abhishek Shah Reviewed-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/net/netfilter/nf_tables.h | 1 + net/netfilter/nf_tables_api.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index b8890ace0f879..0daad6e63ccb2 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -1635,6 +1635,7 @@ struct nftables_pernet { struct list_head module_list; struct list_head notify_list; struct mutex commit_mutex; + u64 table_handle; unsigned int base_seq; u8 validate_state; }; diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 8b6ee9df817fb..e171257739c2f 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -32,7 +32,6 @@ static LIST_HEAD(nf_tables_objects); static LIST_HEAD(nf_tables_flowtables); static LIST_HEAD(nf_tables_destroy_list); static DEFINE_SPINLOCK(nf_tables_destroy_list_lock); -static u64 table_handle; enum { NFT_VALIDATE_SKIP = 0, @@ -1235,7 +1234,7 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info, INIT_LIST_HEAD(&table->flowtables); table->family = family; table->flags = flags; - table->handle = ++table_handle; + table->handle = ++nft_net->table_handle; if (table->flags & NFT_TABLE_F_OWNER) table->nlpid = NETLINK_CB(skb).portid; -- 2.35.1