mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
rcu: Fix buffer overflow in print_cpu_stall_info()
[ Upstream commit 3758f7d9917bd7ef0482c4184c0ad673b4c4e069 ]
The rcuc-starvation output from print_cpu_stall_info() might overflow the
buffer if there is a huge difference in jiffies difference. The situation
might seem improbable, but computers sometimes get very confused about
time, which can result in full-sized integers, and, in this case,
buffer overflow.
Also, the unsigned jiffies difference is printed using %ld, which is
normally for signed integers. This is intentional for debugging purposes,
but it is not obvious from the code.
This commit therefore changes sprintf() to snprintf() and adds a
clarifying comment about intention of %ld format.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 245a629825
("rcu: Dump rcuc kthread status for CPUs not reporting quiescent state")
Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
32d988f48e
commit
afb39909bf
1 changed files with 2 additions and 1 deletions
|
@ -503,7 +503,8 @@ static void print_cpu_stall_info(int cpu)
|
||||||
rcu_dynticks_in_eqs(rcu_dynticks_snap(cpu));
|
rcu_dynticks_in_eqs(rcu_dynticks_snap(cpu));
|
||||||
rcuc_starved = rcu_is_rcuc_kthread_starving(rdp, &j);
|
rcuc_starved = rcu_is_rcuc_kthread_starving(rdp, &j);
|
||||||
if (rcuc_starved)
|
if (rcuc_starved)
|
||||||
sprintf(buf, " rcuc=%ld jiffies(starved)", j);
|
// Print signed value, as negative values indicate a probable 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",
|
pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%04x/%ld/%#lx softirq=%u/%u fqs=%ld%s%s\n",
|
||||||
cpu,
|
cpu,
|
||||||
"O."[!!cpu_online(cpu)],
|
"O."[!!cpu_online(cpu)],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue