linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing: fprobe: Fix RCU warning message in list traversal
@ 2025-04-10 12:22 Breno Leitao
  2025-04-15  7:42 ` Antonio Quartulli
  2025-05-09 14:30 ` Matthieu Baerts
  0 siblings, 2 replies; 4+ messages in thread
From: Breno Leitao @ 2025-04-10 12:22 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-kernel, linux-trace-kernel, kernel-team, Breno Leitao

When CONFIG_PROVE_RCU_LIST is enabled, fprobe triggers the following
warning:

    WARNING: suspicious RCU usage
    kernel/trace/fprobe.c:457 RCU-list traversed in non-reader section!!

    other info that might help us debug this:
	#1: ffffffff863c4e08 (fprobe_mutex){+.+.}-{4:4}, at: fprobe_module_callback+0x7b/0x8c0

    Call Trace:
	fprobe_module_callback
	notifier_call_chain
	blocking_notifier_call_chain

This warning occurs because fprobe_remove_node_in_module() traverses an
RCU list using RCU primitives without holding an RCU read lock. However,
the function is only called from fprobe_module_callback(), which holds
the fprobe_mutex lock that provides sufficient protection for safely
traversing the list.

Fix the warning by specifying the locking design to the
CONFIG_PROVE_RCU_LIST mechanism. Add the lockdep_is_held() argument to
hlist_for_each_entry_rcu() to inform the RCU checker that fprobe_mutex
provides the required protection.

Fixes: a3dc2983ca7b90 ("tracing: fprobe: Cleanup fprobe hash when module unloading")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 kernel/trace/fprobe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index 95c6e3473a76b..ba7ff14f5339b 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -454,7 +454,8 @@ static void fprobe_remove_node_in_module(struct module *mod, struct hlist_head *
 	struct fprobe_hlist_node *node;
 	int ret = 0;
 
-	hlist_for_each_entry_rcu(node, head, hlist) {
+	hlist_for_each_entry_rcu(node, head, hlist,
+				 lockdep_is_held(&fprobe_mutex)) {
 		if (!within_module(node->addr, mod))
 			continue;
 		if (delete_fprobe_node(node))

---
base-commit: 3b07108ada81a8ebcebf1fe61367b4e436c895bd
change-id: 20250410-fprobe-dfe91798f03c

Best regards,
-- 
Breno Leitao <leitao@debian.org>


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

* Re: [PATCH] tracing: fprobe: Fix RCU warning message in list traversal
  2025-04-10 12:22 [PATCH] tracing: fprobe: Fix RCU warning message in list traversal Breno Leitao
@ 2025-04-15  7:42 ` Antonio Quartulli
  2025-05-09 14:30 ` Matthieu Baerts
  1 sibling, 0 replies; 4+ messages in thread
From: Antonio Quartulli @ 2025-04-15  7:42 UTC (permalink / raw)
  To: Breno Leitao, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-kernel, linux-trace-kernel, kernel-team



On 10/04/2025 14:22, Breno Leitao wrote:
> When CONFIG_PROVE_RCU_LIST is enabled, fprobe triggers the following
> warning:
> 
>      WARNING: suspicious RCU usage
>      kernel/trace/fprobe.c:457 RCU-list traversed in non-reader section!!
> 
>      other info that might help us debug this:
> 	#1: ffffffff863c4e08 (fprobe_mutex){+.+.}-{4:4}, at: fprobe_module_callback+0x7b/0x8c0
> 
>      Call Trace:
> 	fprobe_module_callback
> 	notifier_call_chain
> 	blocking_notifier_call_chain
> 
> This warning occurs because fprobe_remove_node_in_module() traverses an
> RCU list using RCU primitives without holding an RCU read lock. However,
> the function is only called from fprobe_module_callback(), which holds
> the fprobe_mutex lock that provides sufficient protection for safely
> traversing the list.
> 
> Fix the warning by specifying the locking design to the
> CONFIG_PROVE_RCU_LIST mechanism. Add the lockdep_is_held() argument to
> hlist_for_each_entry_rcu() to inform the RCU checker that fprobe_mutex
> provides the required protection.
> 
> Fixes: a3dc2983ca7b90 ("tracing: fprobe: Cleanup fprobe hash when module unloading")
> Signed-off-by: Breno Leitao <leitao@debian.org>

I just hit this issue and I verified that the patch actually solves it 
without causing side effects.

FWIW

Tested-by: Antonio Quartulli <antonio@mandelbit.com>

-- 
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl
https://www.mandelbit.com


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

* Re: [PATCH] tracing: fprobe: Fix RCU warning message in list traversal
  2025-04-10 12:22 [PATCH] tracing: fprobe: Fix RCU warning message in list traversal Breno Leitao
  2025-04-15  7:42 ` Antonio Quartulli
@ 2025-05-09 14:30 ` Matthieu Baerts
  2025-05-09 21:55   ` Masami Hiramatsu
  1 sibling, 1 reply; 4+ messages in thread
From: Matthieu Baerts @ 2025-05-09 14:30 UTC (permalink / raw)
  To: Breno Leitao, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-kernel, linux-trace-kernel, kernel-team

Hi Breno,

On 10/04/2025 14:22, Breno Leitao wrote:
> When CONFIG_PROVE_RCU_LIST is enabled, fprobe triggers the following
> warning:
> 
>     WARNING: suspicious RCU usage
>     kernel/trace/fprobe.c:457 RCU-list traversed in non-reader section!!
> 
>     other info that might help us debug this:
> 	#1: ffffffff863c4e08 (fprobe_mutex){+.+.}-{4:4}, at: fprobe_module_callback+0x7b/0x8c0
> 
>     Call Trace:
> 	fprobe_module_callback
> 	notifier_call_chain
> 	blocking_notifier_call_chain
> 
> This warning occurs because fprobe_remove_node_in_module() traverses an
> RCU list using RCU primitives without holding an RCU read lock. However,
> the function is only called from fprobe_module_callback(), which holds
> the fprobe_mutex lock that provides sufficient protection for safely
> traversing the list.
> 
> Fix the warning by specifying the locking design to the
> CONFIG_PROVE_RCU_LIST mechanism. Add the lockdep_is_held() argument to
> hlist_for_each_entry_rcu() to inform the RCU checker that fprobe_mutex
> provides the required protection.

@Breno: thank you for the patch, I have it applied for a while on a
branch dedicated to our CI to avoid false positive reports.

Tested-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>


Hopefully this fix can be sent to Linus before the v6.15 release :)

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


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

* Re: [PATCH] tracing: fprobe: Fix RCU warning message in list traversal
  2025-05-09 14:30 ` Matthieu Baerts
@ 2025-05-09 21:55   ` Masami Hiramatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2025-05-09 21:55 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: Breno Leitao, Steven Rostedt, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel, kernel-team

On Fri, 9 May 2025 16:30:08 +0200
Matthieu Baerts <matttbe@kernel.org> wrote:

> Hi Breno,
> 
> On 10/04/2025 14:22, Breno Leitao wrote:
> > When CONFIG_PROVE_RCU_LIST is enabled, fprobe triggers the following
> > warning:
> > 
> >     WARNING: suspicious RCU usage
> >     kernel/trace/fprobe.c:457 RCU-list traversed in non-reader section!!
> > 
> >     other info that might help us debug this:
> > 	#1: ffffffff863c4e08 (fprobe_mutex){+.+.}-{4:4}, at: fprobe_module_callback+0x7b/0x8c0
> > 
> >     Call Trace:
> > 	fprobe_module_callback
> > 	notifier_call_chain
> > 	blocking_notifier_call_chain
> > 
> > This warning occurs because fprobe_remove_node_in_module() traverses an
> > RCU list using RCU primitives without holding an RCU read lock. However,
> > the function is only called from fprobe_module_callback(), which holds
> > the fprobe_mutex lock that provides sufficient protection for safely
> > traversing the list.
> > 
> > Fix the warning by specifying the locking design to the
> > CONFIG_PROVE_RCU_LIST mechanism. Add the lockdep_is_held() argument to
> > hlist_for_each_entry_rcu() to inform the RCU checker that fprobe_mutex
> > provides the required protection.
> 
> @Breno: thank you for the patch, I have it applied for a while on a
> branch dedicated to our CI to avoid false positive reports.
> 
> Tested-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

Oops, I missed this patch.

Let me pick it up and send it urgently.

Thank you,

> 
> 
> Hopefully this fix can be sent to Linus before the v6.15 release :)
> 
> Cheers,
> Matt
> -- 
> Sponsored by the NGI0 Core fund.
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

end of thread, other threads:[~2025-05-09 21:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 12:22 [PATCH] tracing: fprobe: Fix RCU warning message in list traversal Breno Leitao
2025-04-15  7:42 ` Antonio Quartulli
2025-05-09 14:30 ` Matthieu Baerts
2025-05-09 21:55   ` Masami Hiramatsu

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