RCU Archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Nikita Kiryushin <kiryushin@ancud.ru>,
	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 v4] rcu-tasks: Fix show_rcu_tasks_trace_gp_kthread buffer overflow
Date: Wed, 27 Mar 2024 11:31:01 -0700	[thread overview]
Message-ID: <608b2ed9-a7fa-482d-b1e5-e5c2ad5849c7@paulmck-laptop> (raw)
In-Reply-To: <20240327135246.54cdb58e@gandalf.local.home>

On Wed, Mar 27, 2024 at 01:52:46PM -0400, Steven Rostedt wrote:
> On Wed, 27 Mar 2024 20:47:47 +0300
> Nikita Kiryushin <kiryushin@ancud.ru> wrote:
> 
> > There is a possibility of buffer overflow in
> > show_rcu_tasks_trace_gp_kthread() if counters, passed
> > to sprintf() are huge. Counter numbers, needed for this
> > are unrealistically high, but buffer overflow is still
> > possible.
> > 
> > Use snprintf() with buffer size instead of sprintf().
> > 
> 
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Queued and pushed, thank you both!

							Thanx, Paul

> -- Steve
> 
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> > 
> > Fixes: edf3775f0ad6 ("rcu-tasks: Add count for idle tasks on offline CPUs")
> > Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
> > ---
> > v4: Change ARRAY_SIZE to sizeof() as more idiomatic
> > as Steven Rostedt <rostedt@goodmis.org> suggested
> > v3: Fixed commit message
> > v2: Use snprintf() as
> > Steven Rostedt <rostedt@goodmis.org> suggested.
> >  kernel/rcu/tasks.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
> > index 147b5945d67a..2a453de9f3d9 100644
> > --- a/kernel/rcu/tasks.h
> > +++ b/kernel/rcu/tasks.h
> > @@ -1994,7 +1994,7 @@ void show_rcu_tasks_trace_gp_kthread(void)
> >  {
> >  	char buf[64];
> >  
> > -	sprintf(buf, "N%lu h:%lu/%lu/%lu",
> > +	snprintf(buf, sizeof(buf), "N%lu h:%lu/%lu/%lu",
> >  		data_race(n_trc_holdouts),
> >  		data_race(n_heavy_reader_ofl_updates),
> >  		data_race(n_heavy_reader_updates),
> 

      reply	other threads:[~2024-03-27 18:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 17:48 [PATCH] rcu-tasks: Update show_rcu_tasks_trace_gp_kthread buffer size 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
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 [this message]

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=608b2ed9-a7fa-482d-b1e5-e5c2ad5849c7@paulmck-laptop \
    --to=paulmck@kernel.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=qiang.zhang1211@gmail.com \
    --cc=quic_neeraju@quicinc.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).