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>,
Sachin Sant <sachinp@linux.ibm.com>
Subject: Re: [GIT PULL] tracing: Prevent trace_marker being bigger than unsigned short
Date: Mon, 4 Mar 2024 20:20:09 -0500 [thread overview]
Message-ID: <c73feaa6-ec84-4792-a624-7693d9bec44a@efficios.com> (raw)
In-Reply-To: <20240304194343.57a6a541@gandalf.local.home>
On 2024-03-04 19:43, Steven Rostedt wrote:
> On Mon, 4 Mar 2024 16:17:15 -0800
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
>> On Mon, 4 Mar 2024 at 15:50, Steven Rostedt <rostedt@goodmis.org> wrote:
>>>
>>> But this still isn't fixing anything. It's just adding a limit.
>>
>> Limiting things to a common maximum size is a good thing. The kernel
>> limits much more important things for very good reasons.
>>
>> The kernel really shouldn't have big strings. EVER. And it literally
>> shows in our kernel infrastructure. It showed in that vsnprintf
>> precision thing. It shows in our implementation choices, where we tend
>> to have simplistic implementations because doing things a byte at a
>> time is simple and cheap when the strings are limited in size (and we
>> don't want fancy and can't use vector state anyway).
>>
>> If something as core as a pathname can be limited to 4kB, then
>> something as unimportant as a trace string had better be limited too.
>> Because we simply DO NOT WANT to have to deal with longer strings in
>> the kernel.
>>
>
> So I made three patches that do basically what you want. And as a bonus,
> it's not really an arbitrary limit but based on trace_seq size.
>
> The first patch will be removing the precision check, as that's not needed.
>
> The second patch is to remove the dependency between trace_seq and
> PAGE_SIZE, as its size really can just be 8K for all architectures. Which
> has the side effect of limiting the size of trace_marker, as its size is
> limited by the trace_seq size.
>
> Finally, because the trace_seq defines the max output that a trace_event
> can write (for all its fields), the extra data of a print event could
> possibly overflow that, which will cause the event not to print, and just
> an "OVERFLOW" output would show in the trace buffer. So I used the
> TRACE_SEQ_SIZE / 2 as the max size that trace_marker can read, which
> happens to be 4K.
Steven, see my other reply. This is backwards.
You can leave the trace_seq as is if you want. It's the trace marking
input size that should be #define to 4kB, not defined as
half-the-size-of-an-internal-buffer-that-happens-to-be-8k.
Then add a BUILD_BUG_ON() in the output code to make sure the output
buffer is always large enough.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2024-03-05 1:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-02 16:12 [GIT PULL] tracing: Prevent trace_marker being bigger than unsigned short Steven Rostedt
2024-03-02 17:24 ` Linus Torvalds
2024-03-02 19:59 ` Steven Rostedt
2024-03-02 20:25 ` Linus Torvalds
2024-03-02 20:33 ` Linus Torvalds
2024-03-02 20:47 ` Steven Rostedt
2024-03-02 20:55 ` Linus Torvalds
2024-03-03 12:59 ` Steven Rostedt
2024-03-03 13:02 ` Steven Rostedt
2024-03-03 17:38 ` Linus Torvalds
2024-03-03 19:07 ` Steven Rostedt
2024-03-03 20:09 ` Linus Torvalds
2024-03-03 21:00 ` Steven Rostedt
2024-03-04 21:42 ` Steven Rostedt
2024-03-04 21:50 ` Linus Torvalds
2024-03-04 22:10 ` Steven Rostedt
2024-03-04 23:20 ` Linus Torvalds
2024-03-04 23:47 ` Steven Rostedt
2024-03-04 23:52 ` Steven Rostedt
2024-03-05 0:17 ` Linus Torvalds
2024-03-05 0:43 ` Steven Rostedt
2024-03-05 1:20 ` Mathieu Desnoyers [this message]
2024-03-02 20:26 ` Steven Rostedt
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=c73feaa6-ec84-4792-a624-7693d9bec44a@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sachinp@linux.ibm.com \
--cc=torvalds@linux-foundation.org \
/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