Skip to content

Commit 33be3ff

Browse files
committed
Merge patch series "exit: change the release_task() paths to call flush_sigqueue() lockless"
Oleg Nesterov <[email protected]> says: Change the release_task() paths to call flush_sigqueue() lockless. * patches from https://lore.kernel.org/r/[email protected]: exit: kill the pointless __exit_signal()->clear_tsk_thread_flag(TIF_SIGPENDING) exit: change the release_task() paths to call flush_sigqueue() lockless Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 2014c95 + 4396611 commit 33be3ff

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

kernel/exit.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,12 @@ static void __exit_signal(struct task_struct *tsk)
200200
__unhash_process(tsk, group_dead);
201201
write_sequnlock(&sig->stats_lock);
202202

203-
/*
204-
* Do this under ->siglock, we can race with another thread
205-
* doing sigqueue_free() if we have SIGQUEUE_PREALLOC signals.
206-
*/
207-
flush_sigqueue(&tsk->pending);
208203
tsk->sighand = NULL;
209204
spin_unlock(&sighand->siglock);
210205

211206
__cleanup_sighand(sighand);
212-
clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
213-
if (group_dead) {
214-
flush_sigqueue(&sig->shared_pending);
207+
if (group_dead)
215208
tty_kref_put(tty);
216-
}
217209
}
218210

219211
static void delayed_put_task_struct(struct rcu_head *rhp)
@@ -279,6 +271,16 @@ void release_task(struct task_struct *p)
279271
proc_flush_pid(thread_pid);
280272
put_pid(thread_pid);
281273
release_thread(p);
274+
/*
275+
* This task was already removed from the process/thread/pid lists
276+
* and lock_task_sighand(p) can't succeed. Nobody else can touch
277+
* ->pending or, if group dead, signal->shared_pending. We can call
278+
* flush_sigqueue() lockless.
279+
*/
280+
flush_sigqueue(&p->pending);
281+
if (thread_group_leader(p))
282+
flush_sigqueue(&p->signal->shared_pending);
283+
282284
put_task_struct_rcu_user(p);
283285

284286
p = leader;

0 commit comments

Comments
 (0)