From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.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 20:24:04 -0500 [thread overview]
Message-ID: <20241215202404.06f7be8f@batman.local.home> (raw)
In-Reply-To: <CAHk-=wh5jE5ARarmYNdL4sja36_e-mnejv3zRMC62Jzn-a3omw@mail.gmail.com>
On Sun, 15 Dec 2024 09:23:18 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> And dammit, you must have known this code was garbage, because when I
> do a "git blame", I see your name on that test_can_verify_check()
> function.
Yes, that was added in the same commit that added the
trace_check_vprintk() code.
>
> Basically, you are walking the va_list in invalid ways, because you
> want to use vsnprintf() in invalid ways. As part of that walk, you are
> (a) fundamentally mis-using va_list and (b) modifying the format
> string as you go along (both in the sense of actually changing the
> format string, but also switching that format pointer around).
>
> My issue with this is that (b) was buggy, but it was a bug that came
> from a much more *fundamental* bug - the misuse of vsnprintf. Which
> is why I'm saying "rip it out". Because your fix is fixing symptoms.
> It's not fixing the fact that you are doing things that are wrong.
I'm not disagreeing with you. I didn't like the code when I wrote it,
but I did write it because it was the only way I could stop the "%s"
bug. Last night, thinking about this, I think I have another solution
that can be added to the test_event_printk() and flag the fields that
can be printed via "%s" to make sure that they are correct *before*
processing the vsnprintf() code. That should give the same warning and
checks as the trace_check_vprintf().
I would also add a check in the vsnprintf() that uses
__get_kernel_nofault() like you suggested.
>
> Looking up more, I also think the whole "replace "%p" with "%px" is
> broken and wrong.
>
> Isn't every single case of '%p' in this context from a TP_printk() situation?
>
> IOW, instead of dynamically creating a temporary buffer and adding
> that 'x' by hand, why wasn't that just a 'sed' script and done
> statically?
>
> In fact, wouldn't *most* of the sanity checking be possible to just do
> entirely statically instead of at runtime?
>
> Yeah, yeah, there's more than a few '%p' users, but
>
> git grep 'TP_printk.*%p[^A-Za-z]' | wc
>
> shows that it's manageable. That probably misses some multi-line
> cases, but still - doing this kind of "rewrite constant string at
> runtime because we didn't do it statically" seems *wrong*.
>
> And in this case, that wrongness was literally the cause of the bug.
I'm also OK with that. Should that be done for 6.13 or something to be
added for 6.14?
-- Steve
next prev parent reply other threads:[~2024-12-16 1:24 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
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 [this message]
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=20241215202404.06f7be8f@batman.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=monstr@monstr.eu \
--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®