[PATCH] coccinelle: locks: call_kern: Add rcu_read_lock case
From: GONG, Ruiqi
Date: Thu Aug 08 2024 - 23:22:42 EST
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@xxxxxxxxxx>
---
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