Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp877301pxk; Thu, 17 Sep 2020 20:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL8WTMIvT1ActSR8lOf/PMATYFIbs+cnublEl0NEWhkfkOFS2yPUnzTOTRmHXgYjPoydCs X-Received: by 2002:a17:906:14ca:: with SMTP id y10mr11218082ejc.542.1600398311601; Thu, 17 Sep 2020 20:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398311; cv=none; d=google.com; s=arc-20160816; b=eLyd0F8gfUxhzq/ql8eFegnWgj7+aa4CVSWqHYa2XcIXW7aBE/Hx9eiYj117p/dOm5 kQScPBodv+wvxSwcy3xHwyOBBgzU1lb8px0ylaAbsjV+Eg5aCodGeSSh0f21piP+w7Z2 f0zm2wILgBDLGZUo/xbAlNTOSzh9dvbp4YENa/Aeol2YmjJq1wQ+TV/xVKwYInXdtx7O AQnMCe6LbBCsMMbyN563H3QXdxsL6Rxv0bi5lLe+v115316vxOiU5t15MjQM2JFk+bcG so52x0ME1pSxSnqdlFNLlpRjH+AnbxlPFysAZi2MvZN98QJOx1y/I755dNR6UtfG2Ke6 RpBA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fshZTmvJa2HDoIbxYrtqxVF9RxW2HMI9pQshxngPkyI=; b=TphIFB4kftaGwp3Vr8HA+YU8CPS0XqqfnPy6SvFELG1tsYjs+NX+p1GFfR7jxTgXHj SxRDddcqQSkfOcwr/yI+NvCsfCT45/qAJaqYwANkJWyA0rCFxbIHHyW/MUpUswYFoq7J UgiiqJ2fp7e7fsyaiQ40v0QhGV0Tsq3F7XWPNGxQRt7C43cooxjXbbEAj3OsYksiCmAN S2vQpMIOltyE5wgrzp1GtPJuVQosd0mJA7Wn8oPBrhL2JfWQqUHf7CBKarXVxY1Bqw7z CIJ2Gj0fh7jz8mmH+sHcK7t1tyU3T1lBgJEQnqP423fP96Y4IAPy6aJylYAhPSSjg+lg sWYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RQeTPu71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si1231102ejj.566.2020.09.17.20.04.48; Thu, 17 Sep 2020 20:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RQeTPu71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729792AbgIRDAm (ORCPT + 99 others); Thu, 17 Sep 2020 23:00:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:53924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727567AbgIRCFe (ORCPT ); Thu, 17 Sep 2020 22:05:34 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 315BE235FD; Fri, 18 Sep 2020 02:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394734; bh=cNeWonc/Mz2ib66EIcvihiYK231C6cYC3pINlfnMSo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQeTPu717YKI0SvHzRcgByP2XCNywrTj8sHXzXD/kuNZD3THFcykFDOXSKmyTr0uk ZsQJkArqKB3+1WRWvuzs4AQIximt4ITpGHmtNLQ4Y3l+WSVQD2kz4vK7lKB5nsjvMB qjvm3Hme4AkkJ847wPu+V1UoLlBp2DjfWUl5p5/0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qian Cai , Florian Westphal , Pablo Neira Ayuso , Sasha Levin , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 215/330] netfilter: nf_tables: silence a RCU-list warning in nft_table_lookup() Date: Thu, 17 Sep 2020 21:59:15 -0400 Message-Id: <20200918020110.2063155-215-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qian Cai [ Upstream commit 0a6a9515fe390976cd762c52d8d4f446d7a14285 ] It is safe to traverse &net->nft.tables with &net->nft.commit_mutex held using list_for_each_entry_rcu(). Silence the PROVE_RCU_LIST false positive, WARNING: suspicious RCU usage net/netfilter/nf_tables_api.c:523 RCU-list traversed in non-reader section!! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 1 lock held by iptables/1384: #0: ffffffff9745c4a8 (&net->nft.commit_mutex){+.+.}, at: nf_tables_valid_genid+0x25/0x60 [nf_tables] Call Trace: dump_stack+0xa1/0xea lockdep_rcu_suspicious+0x103/0x10d nft_table_lookup.part.0+0x116/0x120 [nf_tables] nf_tables_newtable+0x12c/0x7d0 [nf_tables] nfnetlink_rcv_batch+0x559/0x1190 [nfnetlink] nfnetlink_rcv+0x1da/0x210 [nfnetlink] netlink_unicast+0x306/0x460 netlink_sendmsg+0x44b/0x770 ____sys_sendmsg+0x46b/0x4a0 ___sys_sendmsg+0x138/0x1a0 __sys_sendmsg+0xb6/0x130 __x64_sys_sendmsg+0x48/0x50 do_syscall_64+0x69/0xf4 entry_SYSCALL_64_after_hwframe+0x49/0xb3 Signed-off-by: Qian Cai Acked-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 2023650c27249..ff2d2b514506e 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -456,7 +456,8 @@ static struct nft_table *nft_table_lookup(const struct net *net, if (nla == NULL) return ERR_PTR(-EINVAL); - list_for_each_entry_rcu(table, &net->nft.tables, list) { + list_for_each_entry_rcu(table, &net->nft.tables, list, + lockdep_is_held(&net->nft.commit_mutex)) { if (!nla_strcmp(nla, table->name) && table->family == family && nft_active_genmask(table, genmask)) -- 2.25.1