mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Michal Simek <monstr@monstr.eu>
Subject: Re: [GIT PULL] ftrace: Fixes for v6.13
Date: Sun, 15 Dec 2024 07:42:35 -0500	[thread overview]
Message-ID: <69db591d-08b0-47e7-a8cc-bdaf3e9d4678@efficios.com> (raw)
In-Reply-To: <20241215050517.050e9d83@gandalf.local.home>

On 2024-12-15 05:05, Steven Rostedt wrote:
> On Sat, 14 Dec 2024 21:19:01 -0800
> Linus Torvalds <torvalds@linux-foundation.org> wrote:

[...]

>>
>> Just disable it unconditionally.
>>
> 
> I can do that, but I'm not looking forward to seeing random crashes in the
> trace event code again :-(
> 
> Honestly, I did not like this code when I wrote it, but I have no idea how
> to stop the "%s" bug from happening before it gets out to production. This
> worked. Do you have any suggestions for alternatives?

IMHO, deferred execution of TP_printk() code in kernel context is
a fundamental mistake causing all those problems. This opens the
door to store pointers to strings (or anything else really)
that sit in kernel modules which can be unloaded between
tracing and TP_printk() execution, or as we are seeing here
pointers to data which can be mapped at different addresses
across kernel reboot, into the ring buffer.

If TP_printk() don't have access to load data from random kernel
memory in the first place, and can only read from the buffer, we
would not be having those misuses, and there would be nothing to
work-around as the strings/data would all be serialized into the
ring buffer.

In LTTng we've taken the approach to only read the trace data
at post-processing from user-space (we don't have the equivalent
of TP_printk(), and that's on purpose).

I wonder if we could keep the ftrace trace_pipe pretty-printing
behavior, while isolating the TP_printk() execution into a
userspace process which would only map the ring buffer ? This way,
users trying to misuse TP_printk() would get immediate feedback
about their mistake because they cannot print the trace. We could
print a dmesg warning about crash of a usermode helper program,
for instance.

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  parent reply	other threads:[~2024-12-15 12:42 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-14 23:21 Steven Rostedt
2024-12-15  0:37 ` Linus Torvalds
2024-12-15  3:04   ` Steven Rostedt
2024-12-15  3:12     ` Steven Rostedt
2024-12-15  4:06       ` Linus Torvalds
2024-12-15  4:11         ` Linus Torvalds
2024-12-15  4:38           ` Steven Rostedt
2024-12-15  5:19             ` Linus Torvalds
2024-12-15 10:05               ` Steven Rostedt
2024-12-15 10:25                 ` Steven Rostedt
2024-12-15 12:42                 ` Mathieu Desnoyers [this message]
2024-12-15 13:47                   ` Steven Rostedt
2024-12-15 14:39                     ` Mathieu Desnoyers
2024-12-15 13:51                 ` Steven Rostedt
2024-12-15 17:23                 ` Linus Torvalds
2024-12-15 21:40                   ` Theodore Ts'o
2024-12-16  1:09                     ` Steven Rostedt
2024-12-16  1:24                   ` Steven Rostedt
2024-12-16 13:33                     ` Steven Rostedt
2024-12-16 18:00                       ` Linus Torvalds
2024-12-16 17:59                     ` Linus Torvalds
2024-12-16 18:39                       ` Steven Rostedt
2024-12-15  4:00     ` Linus Torvalds
2024-12-15  4:23       ` Steven Rostedt
2024-12-15  4:37         ` Linus Torvalds
2024-12-15  4:53           ` Steven Rostedt
2024-12-15  5:20             ` Linus Torvalds
2024-12-15  4:48 ` Al Viro
2024-12-15  5:05   ` Steven Rostedt
2024-12-15  5:11     ` Steven Rostedt
2024-12-17 16:39 Steven Rostedt
2024-12-17 17:25 ` pr-tracker-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69db591d-08b0-47e7-a8cc-bdaf3e9d4678@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=monstr@monstr.eu \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®