Skip to content

Commit fa3947f

Browse files
committed
netfilter: nf_tables: fix false-positive lockdep splat
jira VUlN-597 subsystem-sync netfilter:nf_tables 4.18.0-511 commit-author Florian Westphal <fw@strlen.de> commit b9f052d upstream-diff Had to synch to the use of inline from the rocky8_10 branch. ->abort invocation may cause splat on debug kernels: WARNING: suspicious RCU usage net/netfilter/nft_set_pipapo.c:1697 suspicious rcu_dereference_check() usage! [..] rcu_scheduler_active = 2, debug_locks = 1 1 lock held by nft/133554: [..] (nft_net->commit_mutex){+.+.}-{3:3}, at: nf_tables_valid_genid [..] lockdep_rcu_suspicious+0x1ad/0x260 nft_pipapo_abort+0x145/0x180 __nf_tables_abort+0x5359/0x63d0 nf_tables_abort+0x24/0x40 nfnetlink_rcv+0x1a0a/0x22c0 netlink_unicast+0x73c/0x900 netlink_sendmsg+0x7f0/0xc20 ____sys_sendmsg+0x48d/0x760 Transaction mutex is held, so parallel updates are not possible. Switch to _protected and check mutex is held for lockdep enabled builds. Fixes: 212ed75 ("netfilter: nf_tables: integrate pipapo into commit protocol") Signed-off-by: Florian Westphal <fw@strlen.de> (cherry picked from commit b9f052d) Signed-off-by: Greg Rose <g.v.rose@ciq.com>
1 parent 58786cb commit fa3947f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

net/netfilter/nft_set_pipapo.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,17 @@ static void nft_pipapo_commit(const struct nft_set *set)
15931593
priv->clone = new_clone;
15941594
}
15951595

1596+
static bool inline nft_pipapo_transaction_mutex_held(const struct nft_set *set)
1597+
{
1598+
#ifdef CONFIG_PROVE_LOCKING
1599+
const struct net *net = read_pnet(&set->net);
1600+
1601+
return lockdep_is_held(&nft_pernet(net)->commit_mutex);
1602+
#else
1603+
return true;
1604+
#endif
1605+
}
1606+
15961607
static void nft_pipapo_abort(const struct nft_set *set)
15971608
{
15981609
struct nft_pipapo *priv = nft_set_priv(set);
@@ -1601,7 +1612,7 @@ static void nft_pipapo_abort(const struct nft_set *set)
16011612
if (!priv->dirty)
16021613
return;
16031614

1604-
m = rcu_dereference(priv->match);
1615+
m = rcu_dereference_protected(priv->match, nft_pipapo_transaction_mutex_held(set));
16051616

16061617
new_clone = pipapo_clone(m);
16071618
if (IS_ERR(new_clone))

0 commit comments

Comments
 (0)