netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter/nf_tables: silence a RCU-list warning
@ 2020-03-25 14:31 Qian Cai
  2020-03-25 23:13 ` Florian Westphal
  2020-03-26 13:46 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Qian Cai @ 2020-03-25 14:31 UTC (permalink / raw)
  To: pablo, kadlec, fw
  Cc: davem, netfilter-devel, coreteam, netdev, linux-kernel, Qian Cai

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 <cai@lca.pw>
---
 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 38c680f28f15..e398d1491057 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -520,7 +520,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.21.0 (Apple Git-122.2)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter/nf_tables: silence a RCU-list warning
  2020-03-25 14:31 [PATCH] netfilter/nf_tables: silence a RCU-list warning Qian Cai
@ 2020-03-25 23:13 ` Florian Westphal
  2020-03-26 13:46 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2020-03-25 23:13 UTC (permalink / raw)
  To: Qian Cai
  Cc: pablo, kadlec, fw, davem, netfilter-devel, coreteam, netdev,
	linux-kernel

Qian Cai <cai@lca.pw> wrote:
> 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,

[..]

> -	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)) {

Thanks for the patch.

Acked-by: Florian Westphal <fw@strlen.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter/nf_tables: silence a RCU-list warning
  2020-03-25 14:31 [PATCH] netfilter/nf_tables: silence a RCU-list warning Qian Cai
  2020-03-25 23:13 ` Florian Westphal
@ 2020-03-26 13:46 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2020-03-26 13:46 UTC (permalink / raw)
  To: Qian Cai
  Cc: kadlec, fw, davem, netfilter-devel, coreteam, netdev, linux-kernel

On Wed, Mar 25, 2020 at 10:31:42AM -0400, Qian Cai wrote:
> 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!!

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-26 13:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 14:31 [PATCH] netfilter/nf_tables: silence a RCU-list warning Qian Cai
2020-03-25 23:13 ` Florian Westphal
2020-03-26 13:46 ` Pablo Neira Ayuso

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).