Re: [GIT PULL] tracing: Prevent trace_marker being bigger than unsigned short

From: Linus Torvalds
Date: Sun Mar 03 2024 - 12:38:33 EST


On Sun, 3 Mar 2024 at 04:59, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> - trace_seq_printf(s, ": %.*s", max, field->buf);
> + trace_seq_puts(s, ": ");
> + /* Write 1K chunks at a time */
> + p = field->buf;
> + do {
> + int pre = max > 1024 ? 1024 : max;
> + trace_seq_printf(s, "%.*s", pre, p);
> + max -= pre;
> + p += pre;
> + } while (max > 0);

The above loop is complete garbage.

If 'p' is a string, you're randomly just walking past the end of the
string with 'p += pre'

And if 'o' isn't a string but has a fixed size, you shouldn't use '%s'
in the first place, you should just use seq_write().

Just stop. You are doing things entirely wrong, and you're just adding
random code.

I'm not taking *any* fixes from you as things are now, you're once
again only making things worse.

What was wrong with saying "don't do that"? You seem to be bending
over backwards to doing stupid things, and then insisting on doing
them entirely wrong.

Linus