Re: [BUG] printk/nbcon can use RCU illegally prior to CPU online

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

 



On 2024-07-18, Andrew Halaney <ahalaney@xxxxxxxxxx> wrote:
>     [ 5.061942] =============================
>     [ 5.061942] WARNING: suspicious RCU usage
>     [ 5.061942] 5.14.0-467.el9.x86_64+debug #1 Not tainted
>     [ 5.061942] -----------------------------
>     [ 5.061942] kernel/printk/nbcon.c:1118 suspicious rcu_dereference_check() usage!

In Petr Mladek's review of my latest printk-threading series, he pointed
out [0] that I was using the wrong RCU API in rcuwait_has_sleeper().

The patch below was his suggestion, which I was already folding into the
next version of my series.

John Ogness

[0] https://lore.kernel.org/lkml/ZmsLcu2tHmCfLiu0@xxxxxxxxxxxxxxx

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 0951c2c7fb1b..da462661876c 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1181,9 +1181,6 @@ static void nbcon_irq_work(struct irq_work *irq_work)
 
 static inline bool rcuwait_has_sleeper(struct rcuwait *w)
 {
-	bool has_sleeper;
-
-	rcu_read_lock();
 	/*
 	 * Guarantee any new records can be seen by tasks preparing to wait
 	 * before this context checks if the rcuwait is empty.
@@ -1196,10 +1193,7 @@ static inline bool rcuwait_has_sleeper(struct rcuwait *w)
 	 * This pairs with nbcon_kthread_func:A.
 	 */
 	smp_mb(); /* LMM(rcuwait_has_sleeper:A) */
-	has_sleeper = !!rcu_dereference(w->task);
-	rcu_read_unlock();
-
-	return has_sleeper;
+	return rcuwait_active(w);
 }
 
 /**




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux