mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
tracing: Check return value of __register_event() in trace_module_add_events()
trace_module_add_events() ignores the return value of __register_event()
and unconditionally calls __add_event_to_tracers() for each event.
If __register_event() fails (for example, if event_init() fails), the
trace_event_call is not added to ftrace_events list, but
__add_event_to_tracers() still creates a trace_event_file pointing to it.
If module loading subsequently fails and module memory is freed, tracing
state retains a stale trace_event_call pointer in trace_event_file,
leading to a use-after-free when tracefs or tracing subsystem operations
are later executed.
Fix this by checking the return value of __register_event() and only
calling __add_event_to_tracers() if event registration succeeded.
Fixes: ae63b31e4d ("tracing: Separate out trace events from global variables")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/178528487878.124250.14170824576025743236.stgit@devnote2
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
12b80cdbc5
commit
ac8719969e
|
|
@ -3933,8 +3933,8 @@ static void trace_module_add_events(struct module *mod)
|
|||
end = mod->trace_events + mod->num_trace_events;
|
||||
|
||||
for_each_event(call, start, end) {
|
||||
__register_event(*call, mod);
|
||||
__add_event_to_tracers(*call);
|
||||
if (!__register_event(*call, mod))
|
||||
__add_event_to_tracers(*call);
|
||||
}
|
||||
|
||||
update_cache_events(mod);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user