Thread (26 messages) 26 messages, 7 authors, 2025-09-25

Re: [PATCH] tracing: fprobe: fix suspicious rcu usage in fprobe_entry

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2025-09-02 09:17:18
Also in: lkml

Menglong Dong [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index fb127fa95f21..fece0f849c1c 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -269,7 +269,9 @@ static int fprobe_entry(struct ftrace_graph_ent *trace, struct fgraph_ops *gops,
       if (WARN_ON_ONCE(!fregs))
               return 0;

+       rcu_read_lock();
       head = rhltable_lookup(&fprobe_ip_table, &func, fprobe_rht_params);
+       rcu_read_unlock();
       reserved_words = 0;
       rhl_for_each_entry_rcu(node, pos, head, hlist) {
               if (node->addr != func)
Actually this isn't quite right.  I know that it is a false-positive
so that it's actually safe, but if you're going to mark it with
rcu_read_lock, it should cover both the lookup as well as the
dereference which happens in the loop rhl_for_each_entry_rcu.

Thanks,
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help