Skip to content

Commit a841796

Browse files
Paul E. McKenneypaulmck
authored andcommitted
signal: align __lock_task_sighand() irq disabling and RCU
The __lock_task_sighand() function calls rcu_read_lock() with interrupts and preemption enabled, but later calls rcu_read_unlock() with interrupts disabled. It is therefore possible that this RCU read-side critical section will be preempted and later RCU priority boosted, which means that rcu_read_unlock() will call rt_mutex_unlock() in order to deboost itself, but with interrupts disabled. This results in lockdep splats, so this commit nests the RCU read-side critical section within the interrupt-disabled region of code. This prevents the RCU read-side critical section from being preempted, and thus prevents the attempt to deboost with interrupts disabled. It is quite possible that a better long-term fix is to make rt_mutex_unlock() disable irqs when acquiring the rt_mutex structure's ->wait_lock. Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent ec433f0 commit a841796

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

kernel/signal.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,18 +1178,25 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
11781178
{
11791179
struct sighand_struct *sighand;
11801180

1181-
rcu_read_lock();
11821181
for (;;) {
1182+
local_irq_save(*flags);
1183+
rcu_read_lock();
11831184
sighand = rcu_dereference(tsk->sighand);
1184-
if (unlikely(sighand == NULL))
1185+
if (unlikely(sighand == NULL)) {
1186+
rcu_read_unlock();
1187+
local_irq_restore(*flags);
11851188
break;
1189+
}
11861190

1187-
spin_lock_irqsave(&sighand->siglock, *flags);
1188-
if (likely(sighand == tsk->sighand))
1191+
spin_lock(&sighand->siglock);
1192+
if (likely(sighand == tsk->sighand)) {
1193+
rcu_read_unlock();
11891194
break;
1190-
spin_unlock_irqrestore(&sighand->siglock, *flags);
1195+
}
1196+
spin_unlock(&sighand->siglock);
1197+
rcu_read_unlock();
1198+
local_irq_restore(*flags);
11911199
}
1192-
rcu_read_unlock();
11931200

11941201
return sighand;
11951202
}

0 commit comments

Comments
 (0)