[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240809033156.2518473-1-gongruiqi1@huawei.com>
Date: Fri, 9 Aug 2024 11:31:56 +0800
From: "GONG, Ruiqi" <gongruiqi1@...wei.com>
To: Julia Lawall <Julia.Lawall@...ia.fr>, Nicolas Palix
<nicolas.palix@...g.fr>
CC: <cocci@...ia.fr>, <linux-kernel@...r.kernel.org>, Wang Weiyang
<wangweiyang2@...wei.com>
Subject: [PATCH] coccinelle: locks: call_kern: Add rcu_read_lock case
Allocating memory with GFP_KERNEL may cause the thread to be put into
sleep, and doing so within RCU read-side critical section is problematic
as it might cause the grace period to end early and trigger unexpected
objects destruction. Involve rcu_read_lock() into locks/call_kern.cocci,
as this requirement is analogous to other kinds of lock.
Signed-off-by: GONG, Ruiqi <gongruiqi1@...wei.com>
---
scripts/coccinelle/locks/call_kern.cocci | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/coccinelle/locks/call_kern.cocci b/scripts/coccinelle/locks/call_kern.cocci
index 3720f86d67c5..89665ea61642 100644
--- a/scripts/coccinelle/locks/call_kern.cocci
+++ b/scripts/coccinelle/locks/call_kern.cocci
@@ -31,6 +31,7 @@ fn(...) {
when != spin_unlock_irq(...)
when != spin_unlock_irqrestore(...)
when != local_irq_enable(...)
+ when != rcu_read_unlock(...)
when any
GFP_KERNEL@p
... when any
@@ -59,6 +60,8 @@ spin_lock_irq@p1
spin_lock_irqsave@p1
|
local_irq_disable@p1
+|
+rcu_read_lock@p1
)
(...)
... when != read_unlock_irq(...)
@@ -69,6 +72,7 @@ local_irq_disable@p1
when != spin_unlock_irq(...)
when != spin_unlock_irqrestore(...)
when != local_irq_enable(...)
+ when != rcu_read_unlock(...)
fn@p2(...)
@depends on locked && patch@
--
2.25.1
Powered by blists - more mailing lists