linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ring-buffer: Hardening of the persistent buffer
@ 2024-12-17 17:32 Steven Rostedt
  2024-12-17 17:32 ` [PATCH 1/3] ring-buffer: Add uname to match criteria for persistent ring buffer Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Steven Rostedt @ 2024-12-17 17:32 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
	Linus Torvalds


Harden persistent ring buffer:

The persistent ring buffer has some assumptions for it to work correctly.
Currently, those assumptions are not forced. This changes that.

One assumption is that the data in the persistent ring buffer from
the previous boot is for the same kernel that is currently running.
That is now enforced by adding a uname into the meta data and if
the uname does not match, it will reset the data. Note, this is not
meant for forcing this during development, but only for production
where the uname should change when the kernel is updated.

The next assumption is that modules and dynamic events cannot be
trusted in the buffer that's from a previous boot. That's because the
addresses, and possibly even the event types will not match. To prevent
this, module and dynamic events are not even created in any instance
that holds a persistent buffer. This means the "enable" files will
not be there as the directories that are associated with those events
will also not be there, and the events cannot be started in the
persistent ring buffers.

Finally, because the TP_printk() can have various pointers to strings,
force the use of the print_fields() output function as that just iterates
the events fields and prints them while ignoring the TP_printk() format
of the event. In the future, the TP_printk() could be used, but that
would require making a copy of the event data and updating the pointers
before passing to the TP_printk() event and that is out of scrope of
these fixes.

The print_fields() needed one change to update the pointer to the "%s"
that can point into the kernel.


Steven Rostedt (3):
      ring-buffer: Add uname to match criteria for persistent ring buffer
      trace/ring-buffer: Do not create module or dynamic events in boot mapped buffers
      trace/ring-buffer: Do not use TP_printk() formatting for boot mapped buffers

----
 kernel/trace/ring_buffer.c  | 10 ++++++++++
 kernel/trace/trace.c        |  9 +++++++++
 kernel/trace/trace_events.c |  6 ++++++
 kernel/trace/trace_output.c |  3 ++-
 4 files changed, 27 insertions(+), 1 deletion(-)

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

end of thread, other threads:[~2024-12-18  1:53 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 17:32 [PATCH 0/3] ring-buffer: Hardening of the persistent buffer Steven Rostedt
2024-12-17 17:32 ` [PATCH 1/3] ring-buffer: Add uname to match criteria for persistent ring buffer Steven Rostedt
2024-12-17 17:46   ` Linus Torvalds
2024-12-17 18:04     ` Steven Rostedt
2024-12-17 18:19       ` Linus Torvalds
2024-12-17 18:24         ` Linus Torvalds
2024-12-17 18:42           ` Steven Rostedt
2024-12-17 19:22           ` Mathieu Desnoyers
2024-12-17 18:33         ` Steven Rostedt
2024-12-17 18:42           ` Linus Torvalds
2024-12-17 19:01             ` Steven Rostedt
2024-12-17 19:38               ` Linus Torvalds
2024-12-17 19:44                 ` Steven Rostedt
2024-12-17 22:24                   ` Linus Torvalds
2024-12-17 22:53                     ` Steven Rostedt
2024-12-17 23:32                       ` Linus Torvalds
2024-12-18  0:02                         ` Linus Torvalds
2024-12-18  0:48                           ` Steven Rostedt
2024-12-18  0:47                         ` Alexei Starovoitov
2024-12-18  1:26                           ` Linus Torvalds
2024-12-18  1:39                             ` Linus Torvalds
2024-12-18  1:53                               ` Alexei Starovoitov
2024-12-17 19:03             ` Linus Torvalds
2024-12-17 19:07               ` Steven Rostedt
2024-12-17 19:14                 ` Steven Rostedt
2024-12-17 18:17     ` Steven Rostedt
2024-12-17 17:32 ` [PATCH 2/3] trace/ring-buffer: Do not create module or dynamic events in boot mapped buffers Steven Rostedt
2024-12-17 17:32 ` [PATCH 3/3] trace/ring-buffer: Do not use TP_printk() formatting for " Steven Rostedt

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