From: Steven Rostedt <rostedt@goodmis.org>
To: Nikita Kiryushin <kiryushin@ancud.ru>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <quic_neeraju@quicinc.com>,
Joel Fernandes <joel@joelfernandes.org>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun.feng@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] rcu-tasks: Update show_rcu_tasks_trace_gp_kthread buffer size
Date: Tue, 26 Mar 2024 16:28:38 -0400 [thread overview]
Message-ID: <20240326162838.14da4a7c@gandalf.local.home> (raw)
In-Reply-To: <4b3e239d-ab87-4a37-ac1d-af49e1f8f3ee@ancud.ru>
On Tue, 26 Mar 2024 22:55:29 +0300
Nikita Kiryushin <kiryushin@ancud.ru> wrote:
> On 3/26/24 22:22, Steven Rostedt wrote:
> > Why 87? as it's not even word size, and this is on the stack.
> >
> Got 87 as maximal used buffer length (result of
> sprintf(buf, "N%lu h:%lu/%lu/%lu",
> (unsigned long int) -1,
> (unsigned long int) -1,
> (unsigned long int) -1,
> (unsigned long int) -1);
> +1 for terminator.
>
> Is word-size alignment a thing in this case? I thought that char buffers
> are ok to be aligned by 1?
Because it's on the stack, which will likely reserve data in word size.
Thus, buf[87] reserves as much data on the stack as buf[88].
> > Better yet, why not just use snprintf()?
> >
> Seems like a better idea indeed, as if fixes overflows for unpractical cases,
> without added overhead to common cases. The only concern is possible truncation
> of data, that may break some automation (if output is parsed by someone,
> without accounting on it being cut, who knows). But again, it is for pretty unpractical
> values.
>
> Will make a v2 patch with snprintf() with buffer length.
>
> Genuinely look forward to being educated about aspects of aligning array sizes, as
> I do not really understand the limitations.
It's because it's on the stack, but it's always good to align. For
instance, kmalloc() will allocate things in 32 byte chunks.
-- Steve
next prev parent reply other threads:[~2024-03-26 20:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-26 17:48 Nikita Kiryushin
2024-03-26 18:06 ` Paul E. McKenney
2024-03-26 19:22 ` Steven Rostedt
2024-03-26 19:55 ` Nikita Kiryushin
2024-03-26 20:28 ` Steven Rostedt [this message]
2024-03-27 16:36 ` [PATCH v2] " Nikita Kiryushin
2024-03-27 16:46 ` [PATCH v3] rcu-tasks: Fix show_rcu_tasks_trace_gp_kthread buffer overflow Nikita Kiryushin
2024-03-27 16:51 ` [PATCH v2] rcu-tasks: Update show_rcu_tasks_trace_gp_kthread buffer size Steven Rostedt
2024-03-27 17:47 ` [PATCH v4] rcu-tasks: Fix show_rcu_tasks_trace_gp_kthread buffer overflow Nikita Kiryushin
2024-03-27 17:52 ` Steven Rostedt
2024-03-27 18:31 ` Paul E. McKenney
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=20240326162838.14da4a7c@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kiryushin@ancud.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.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
all inboxes | Powered by JetHome®