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 v3] rcu: Fix buffer overlow in print_cpu_stall_info()
Date: Mon, 1 Apr 2024 16:03:12 -0400 [thread overview]
Message-ID: <20240401160312.7b03e568@gandalf.local.home> (raw)
In-Reply-To: <20240401194315.362090-1-kiryushin@ancud.ru>
On Mon, 1 Apr 2024 22:43:15 +0300
Nikita Kiryushin <kiryushin@ancud.ru> wrote:
> rcuc info output in print_cpu_stall_info() contains
> posiible buffer overflow in the case of huge jiffies
> difference. The situation seems improbable, but, buffer
> overflow, still.
>
> Also, unsigned jiffies difference printed as (signed)
> %ld. This is intentional for debugging purposes, but
> it is not obvious from the code.
>
> Change sprintf to snprintf and add clarifying comment
> about intention of %ld format.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 245a62982502 ("rcu: Dump rcuc kthread status for CPUs not reporting quiescent state")
> Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
> ---
> v3: Change intention comment wording as
> Steven Rostedt <rostedt@goodmis.org> suggested
> v2: Remove signed to unsigned print format change as
> Paul E. McKenney <paulmck@kernel.org> suggested, add format
> intention clarification comment
> kernel/rcu/tree_stall.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
> index 5d666428546b..320440b8384e 100644
> --- a/kernel/rcu/tree_stall.h
> +++ b/kernel/rcu/tree_stall.h
> @@ -504,7 +504,8 @@ static void print_cpu_stall_info(int cpu)
> rcu_dynticks_in_eqs(rcu_dynticks_snap(cpu));
> rcuc_starved = rcu_is_rcuc_kthread_starving(rdp, &j);
> if (rcuc_starved)
> - sprintf(buf, " rcuc=%ld jiffies(starved)", j);
> + /* Print signed value, as negative means it is likely a bug */
> + snprintf(buf, sizeof(buf), " rcuc=%ld jiffies(starved)", j);
> pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%04x/%ld/%#lx softirq=%u/%u fqs=%ld%s%s\n",
> cpu,
> "O."[!!cpu_online(cpu)],
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-- Steve
next prev parent reply other threads:[~2024-04-01 20:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 18:19 [PATCH] " Nikita Kiryushin
2024-03-29 17:43 ` Paul E. McKenney
2024-03-29 17:56 ` Nikita Kiryushin
2024-03-29 18:32 ` Steven Rostedt
2024-03-29 22:21 ` Paul E. McKenney
2024-04-01 18:54 ` [PATCH v2] " Nikita Kiryushin
2024-04-01 19:05 ` Steven Rostedt
2024-04-01 19:43 ` [PATCH v3] " Nikita Kiryushin
2024-04-01 20:03 ` Steven Rostedt [this message]
2024-04-01 20:54 ` 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=20240401160312.7b03e568@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®