]> www.infradead.org Git - users/jedix/linux-maple.git/commit
exit: change the release_task() paths to call flush_sigqueue() lockless
authorOleg Nesterov <oleg@redhat.com>
Thu, 6 Feb 2025 15:23:14 +0000 (16:23 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 7 Feb 2025 10:20:57 +0000 (11:20 +0100)
commitfb3bbcfe344e64a46574a638b051ffd78762c12d
tree4238e61fb2e28c787ea9a2936bffaf11fef5ba16
parent2014c95afecee3e76ca4a56956a936e23283f05b
exit: change the release_task() paths to call flush_sigqueue() lockless

A task can block a signal, accumulate up to RLIMIT_SIGPENDING sigqueues,
and exit. In this case __exit_signal()->flush_sigqueue() called with irqs
disabled can trigger a hard lockup, see
https://lore.kernel.org/all/20190322114917.GC28876@redhat.com/

Fortunately, after the recent posixtimer changes sys_timer_delete() paths
no longer try to clear SIGQUEUE_PREALLOC and/or free tmr->sigq, and after
the exiting task passes __exit_signal() lock_task_sighand() can't succeed
and pid_task(tmr->it_pid) will return NULL.

This means that after __exit_signal(tsk) nobody can play with tsk->pending
or (if group_dead) with tsk->signal->shared_pending, so release_task() can
safely call flush_sigqueue() after write_unlock_irq(&tasklist_lock).

TODO:
- we can probably shift posix_cpu_timers_exit() as well
- do_sigaction() can hit the similar problem

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20250206152314.GA14620@redhat.com
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
kernel/exit.c