Say a SQPOLL thread is a member of a thread-group that coredumps. The coredump code uses zap_process() and sends SIGKILL. The SQPOLL thread uses io_sqd_handle_event() and calls get_signal(). It removes SIGKILL from the pending set and returns. The SQPOLL thread breaks out of the loop and drains its own task work. Any pending io_req_task_submit() with REQ_F_FORCE_ASYNC creates a new worker when no other worker is free. So it ends up calling create_io_thread() from a thread whose fatal signal is gone. That means copy_process() allows the creation. It's also possible for an exiting io-wq worker to push new work onto the SQPOLL thread. zap_threads() counts the number of coredumping threads. The coredump client waits in coredump_wait_inactive() untill all threads in the thread-group are parked. The new thread that was created via SQPOLL exits immediately since it got PF_SIGNALED from the parent. The problem is that it sees signal->core_state, links itself onto core_state->tasks and decrements "threads_remaining". But zap_process() never actually counted the new thread. So the count goes to zero too early. So either the coredump misses the thread or it dumps a thread that is still alive. Close that gap and refuse creating a thread while signal->core_state is set. Both sides protect it via siglock so copy_process() and zap_processes() are sure to see each otehr. Fixes: 3bfe6106693b ("io-wq: fork worker threads from original task") Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner (Amutable) --- kernel/fork.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 10be4a0ecb3f..bd97fc7b885b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2491,8 +2491,8 @@ __latent_entropy struct task_struct *copy_process( goto bad_fork_core_free; } - /* Let kill terminate clone/fork in the middle */ - if (fatal_signal_pending(current)) { + /* Let kill or a coredump in progress terminate clone/fork */ + if (fatal_signal_pending(current) || current->signal->core_state) { retval = -EINTR; goto bad_fork_core_free; } -- 2.53.0