diff mbox series

[2/3] trace/ring-buffer: Do not create module or dynamic events in boot mapped buffers

Message ID 20241217173520.483964366@goodmis.org (mailing list archive)
State New
Headers show
Series ring-buffer: Hardening of the persistent buffer | expand

Commit Message

Steven Rostedt Dec. 17, 2024, 5:32 p.m. UTC
From: Steven Rostedt <rostedt@goodmis.org>

When a ring buffer is mapped across boots, an delta is saved between the
addresses of the previous kernel and the current kernel. But this does not
handle module events nor dynamic events.

Simply do not create module or dynamic events to a boot mapped instance.
This will keep them from ever being enabled and therefore not part of the
previous kernel trace.

Cc: stable@vger.kernel.org
Fixes: e645535a954ad ("tracing: Add option to use memmapped memory for trace boot instance")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 77e68efbd43e..d6359318d5c1 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2984,6 +2984,12 @@  trace_create_new_event(struct trace_event_call *call,
 	if (!event_in_systems(call, tr->system_names))
 		return NULL;
 
+	/* Boot mapped instances cannot use modules or dynamic events */
+	if (tr->flags & TRACE_ARRAY_FL_BOOT) {
+		if ((call->flags & TRACE_EVENT_FL_DYNAMIC) || call->module)
+			return NULL;
+	}
+
 	file = kmem_cache_alloc(file_cachep, GFP_TRACE);
 	if (!file)
 		return ERR_PTR(-ENOMEM);