]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfilter: nf_tables: adjust lockdep assertions handling
authorFedor Pchelkin <pchelkin@ispras.ru>
Tue, 24 Jun 2025 11:12:15 +0000 (14:12 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 10 Jul 2025 01:01:22 +0000 (03:01 +0200)
It's needed to check the return value of lockdep_commit_lock_is_held(),
otherwise there's no point in this assertion as it doesn't print any
debug information on itself.

Found by Linux Verification Center (linuxtesting.org) with Svace static
analysis tool.

Fixes: b04df3da1b5c ("netfilter: nf_tables: do not defer rule destruction via call_rcu")
Reported-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 4ec117b31611b3c6d874916a4f2ea40a26d3d93d..620824a56a55c266ef025b1cb5dc6a7d42fa2d75 100644 (file)
@@ -4042,7 +4042,7 @@ void nf_tables_rule_destroy(const struct nft_ctx *ctx, struct nft_rule *rule)
 /* can only be used if rule is no longer visible to dumps */
 static void nf_tables_rule_release(const struct nft_ctx *ctx, struct nft_rule *rule)
 {
-       lockdep_commit_lock_is_held(ctx->net);
+       WARN_ON_ONCE(!lockdep_commit_lock_is_held(ctx->net));
 
        nft_rule_expr_deactivate(ctx, rule, NFT_TRANS_RELEASE);
        nf_tables_rule_destroy(ctx, rule);
@@ -5864,7 +5864,7 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,
                              struct nft_set_binding *binding,
                              enum nft_trans_phase phase)
 {
-       lockdep_commit_lock_is_held(ctx->net);
+       WARN_ON_ONCE(!lockdep_commit_lock_is_held(ctx->net));
 
        switch (phase) {
        case NFT_TRANS_PREPARE_ERROR: