Skip to content

Commit cc5645f

Browse files
nkiryushinurezki
authored andcommitted
rcu-tasks: Fix show_rcu_tasks_trace_gp_kthread buffer overflow
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(). Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: edf3775 ("rcu-tasks: Add count for idle tasks on offline CPUs") Signed-off-by: Nikita Kiryushin <[email protected]> Reviewed-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Uladzislau Rezki (Sony) <[email protected]>
1 parent 5f48fa8 commit cc5645f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/rcu/tasks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,7 @@ void show_rcu_tasks_trace_gp_kthread(void)
19971997
{
19981998
char buf[64];
19991999

2000-
sprintf(buf, "N%lu h:%lu/%lu/%lu",
2000+
snprintf(buf, sizeof(buf), "N%lu h:%lu/%lu/%lu",
20012001
data_race(n_trc_holdouts),
20022002
data_race(n_heavy_reader_ofl_updates),
20032003
data_race(n_heavy_reader_updates),

0 commit comments

Comments
 (0)