mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
signal: Document the RCU protection of ->sighand
__cleanup_sighand() frees sighand without RCU grace period. This is correct but this looks "obviously buggy" and constantly confuses the readers, add the comments to explain how this works. Signed-off-by: Oleg Nesterov <[email protected]> Reviewed-by: Steven Rostedt <[email protected]> Reviewed-by: Rik van Riel <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Pranith Kumar <[email protected]>
This commit is contained in:
parent
eca1a08986
commit
392809b258
2 changed files with 15 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue