probes: Fixes for v6.15-rc6
Masami Hiramatsu (Google)
maintainerHi Linus,
Probes fixes for v6.15-rc6:
- fprobe: Fix RCU warning message in list traversal fprobe_module_callback() using hlist_for_each_entry_rcu() traverse the fprobe list but it locks fprobe_mutex() instead of rcu lock because it is enough. So add lockdep_is_held() to avoid warning.
- tracing: eprobe: Add missing trace_probe_log_clear for eprobe __trace_eprobe_create() uses trace_probe_log but forgot to clear it at exit. Add trace_probe_log_clear() calls.
- tracing: probes: Fix possible race in trace_probe_log APIs trace_probe_log APIs are used in probe event (dynamic_events, kprobe_events and uprobe_events) creation. Only dynamic_events uses the dyn_event_ops_mutex mutex to serialize it. This makes kprobe and uprobe events to lock the same mutex to serialize its creation to avoid race in trace_probe_log APIs.
Please pull the latest probes-fixes-v6.15-rc6 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
probes-fixes-v6.15-rc6
Tag SHA1: f89fdfff7ff5f4b38c783b466e4f78032ce9cea5 Head SHA1: fd837de3c9cb1a162c69bc1fb1f438467fe7f2f5
Breno Leitao (1):
tracing: fprobe: Fix RCU warning message in list traversal
Masami Hiramatsu (Google) (1):
tracing: probes: Fix a possible race in trace_probe_log APIs
Paul Cacheux (1):
tracing: add missing trace_probe_log_clear for eprobes
----
kernel/trace/fprobe.c | 3 ++- kernel/trace/trace_dynevent.c | 16 +++++++++++++++- kernel/trace/trace_dynevent.h | 1 + kernel/trace/trace_eprobe.c | 3 +++ kernel/trace/trace_kprobe.c | 2 +- kernel/trace/trace_probe.c | 9 +++++++++ kernel/trace/trace_uprobe.c | 2 +- 7 files changed, 32 insertions(+), 4 deletions(-)
---------------------------
kernel/trace/fprobe.c +2 -1
@@ -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))
kernel/trace/trace_dynevent.c +15 -1
@@ -16,7 +16,7 @@#include "trace_output.h" /* for trace_event_sem */ #include "trace_dynevent.h" -static DEFINE_MUTEX (dyn_event_ops_mutex); +DEFINE_MUTEX (dyn_event_ops_mutex);static LIST_HEAD (dyn_event_ops_list);bool trace_event_dyn_try_get_ref (struct trace_event_call *dyn_call)
@@ -116,6 +116,20 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *typereturn ret; } +/* +* Locked version of event creation. The event creation must be protected by +* dyn_event_ops_mutex because of protecting trace_probe_log. +*/ +int dyn_event_create (const char *raw_command,struct dyn_event_operations *type) +{ +int ret; + +mutex_lock (&dyn_event_ops_mutex); + ret = type->create (raw_command); +mutex_unlock (&dyn_event_ops_mutex); +return ret; +} +static int create_dyn_event (const char *raw_command) {struct dyn_event_operations *ops;
kernel/trace/trace_dynevent.h +1 -0
@@ -100,6 +100,7 @@ void *dyn_event_seq_next(struct seq_file *m, void *v, loff_t *pos);void dyn_event_seq_stop (struct seq_file *m,void *v);int dyn_events_release_all (struct dyn_event_operations *type);int dyn_event_release (const char *raw_command,struct dyn_event_operations *type); +int dyn_event_create (const char *raw_command,struct dyn_event_operations *type);/* * for_each_dyn_event - iterate over the dyn_event list
kernel/trace/trace_eprobe.c +3 -0
@@ -969,10 +969,13 @@ static int __trace_eprobe_create(int argc, const char *argv[]) goto error; } } +trace_probe_log_clear ();return ret; + parse_error: ret = -EINVAL ; error: +trace_probe_log_clear ();trace_event_probe_cleanup (ep);return ret; }
kernel/trace/trace_kprobe.c +1 -1
@@ -1089,7 +1089,7 @@ static int create_or_delete_trace_kprobe(const char *raw_command)if (raw_command[0 ] =='-' )return dyn_event_release (raw_command, &trace_kprobe_ops); - ret =trace_kprobe_create (raw_command); + ret =dyn_event_create (raw_command, &trace_kprobe_ops);return ret == -ECANCELED ? -EINVAL : ret; }
kernel/trace/trace_probe.c +9 -0
@@ -154,9 +154,12 @@ static const struct fetch_type *find_fetch_type(const char *type, unsigned long }static struct trace_probe_log trace_probe_log; +extern struct mutex dyn_event_ops_mutex;void trace_probe_log_init (const char *subsystem,int argc,const char **argv) { +lockdep_assert_held (&dyn_event_ops_mutex); + trace_probe_log.subsystem = subsystem; trace_probe_log.argc = argc; trace_probe_log.argv = argv;
@@ -165,11 +168,15 @@ void trace_probe_log_init(const char *subsystem, int argc, const char **argv)void trace_probe_log_clear (void ) { +lockdep_assert_held (&dyn_event_ops_mutex); +memset (&trace_probe_log,0 ,sizeof (trace_probe_log)); }void trace_probe_log_set_index (int index) { +lockdep_assert_held (&dyn_event_ops_mutex); + trace_probe_log.index = index; }
@@ -178,6 +185,8 @@ void __trace_probe_log_err(int offset, int err_type)char *command, *p;int i, len =0 , pos =0 ; +lockdep_assert_held (&dyn_event_ops_mutex); +if (!trace_probe_log.argv)return ;
kernel/trace/trace_uprobe.c +1 -1
@@ -741,7 +741,7 @@ static int create_or_delete_trace_uprobe(const char *raw_command)if (raw_command[0 ] =='-' )return dyn_event_release (raw_command, &trace_uprobe_ops); - ret =trace_uprobe_create (raw_command); + ret =dyn_event_create (raw_command, &trace_uprobe_ops);return ret == -ECANCELED ? -EINVAL : ret; }
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
The pull request you sent on Wed, 14 May 2025 00:01:44 +0900:
The pull request you sent on Wed, 14 May 2025 00:01:44 +0900:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gitprobes-fixes-v6.15-rc6
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/405e6c37c89ef0df2bfc7a988820a3df22dacb1b
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html