|
@@ -1275,7 +1275,17 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
|
|
|
local_irq_restore(*flags);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+ /*
|
|
|
+ * This sighand can be already freed and even reused, but
|
|
|
+ * we rely on SLAB_DESTROY_BY_RCU and sighand_ctor() which
|
|
|
+ * initializes ->siglock: this slab can't go away, it has
|
|
|
+ * the same object type, ->siglock can't be reinitialized.
|
|
|
+ *
|
|
|
+ * We need to ensure that tsk->sighand is still the same
|
|
|
+ * after we take the lock, we can race with de_thread() or
|
|
|
+ * __exit_signal(). In the latter case the next iteration
|
|
|
+ * must see ->sighand == NULL.
|
|
|
+ */
|
|
|
spin_lock(&sighand->siglock);
|
|
|
if (likely(sighand == tsk->sighand)) {
|
|
|
rcu_read_unlock();
|