Patch "rcu: Fix buffer overflow in print_cpu_stall_info()" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    rcu: Fix buffer overflow in print_cpu_stall_info()

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rcu-fix-buffer-overflow-in-print_cpu_stall_info.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7757a57813326223913499929819a95aa1762619
Author: Nikita Kiryushin <kiryushin@xxxxxxxx>
Date:   Mon Apr 1 22:43:15 2024 +0300

    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: 245a62982502 ("rcu: Dump rcuc kthread status for CPUs not reporting quiescent state")
    Signed-off-by: Nikita Kiryushin <kiryushin@xxxxxxxx>
    Reviewed-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
    Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 5d666428546b0..b5ec62b2d850a 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 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",
 	       cpu,
 	       "O."[!!cpu_online(cpu)],




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux