Skip to content

Commit a0a91f7

Browse files
committed
netfilter: nf_tables: fix false-positive lockdep splat
jira VULN-430 cve CVE-2023-4244 commit-author Florian Westphal <fw@strlen.de> commit b9f052d ->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: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent ca6e9cf commit a0a91f7

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
@@ -1698,6 +1698,17 @@ static void nft_pipapo_commit(const struct nft_set *set)
16981698
priv->clone = new_clone;
16991699
}
17001700

1701+
static bool nft_pipapo_transaction_mutex_held(const struct nft_set *set)
1702+
{
1703+
#ifdef CONFIG_PROVE_LOCKING
1704+
const struct net *net = read_pnet(&set->net);
1705+
1706+
return lockdep_is_held(&nft_pernet(net)->commit_mutex);
1707+
#else
1708+
return true;
1709+
#endif
1710+
}
1711+
17011712
static void nft_pipapo_abort(const struct nft_set *set)
17021713
{
17031714
struct nft_pipapo *priv = nft_set_priv(set);
@@ -1706,7 +1717,7 @@ static void nft_pipapo_abort(const struct nft_set *set)
17061717
if (!priv->dirty)
17071718
return;
17081719

1709-
m = rcu_dereference(priv->match);
1720+
m = rcu_dereference_protected(priv->match, nft_pipapo_transaction_mutex_held(set));
17101721

17111722
new_clone = pipapo_clone(m);
17121723
if (IS_ERR(new_clone))

0 commit comments

Comments
 (0)