mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: nf_tables: adjust lockdep assertions handling
@ 2025-06-24 11:12 Fedor Pchelkin
  2025-06-24 11:41 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Fedor Pchelkin @ 2025-06-24 11:12 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Fedor Pchelkin, Jozsef Kadlecsik, Florian Westphal,
	netfilter-devel, coreteam, linux-kernel, lvc-project,
	Alexey Khoroshilov

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>
---
 net/netfilter/nf_tables_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 24c71ecb2179..44b909755c86 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4039,7 +4039,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);
@@ -5859,7 +5859,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:
-- 
2.49.0


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

* Re: [PATCH nf] netfilter: nf_tables: adjust lockdep assertions handling
  2025-06-24 11:12 [PATCH nf] netfilter: nf_tables: adjust lockdep assertions handling Fedor Pchelkin
@ 2025-06-24 11:41 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2025-06-24 11:41 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, netfilter-devel, coreteam,
	linux-kernel, lvc-project, Alexey Khoroshilov

Fedor Pchelkin <pchelkin@ispras.ru> wrote:
> 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.

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

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

end of thread, other threads:[~2025-06-24 11:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-24 11:12 [PATCH nf] netfilter: nf_tables: adjust lockdep assertions handling Fedor Pchelkin
2025-06-24 11:41 ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®