From: Jens Axboe axboe@kernel.dk
stable inclusion from stable-v5.10.162 commit 831cb78a2a5e86fe705ef4e3095c7cbc587c6a57 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6LQMS
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=...
--------------------------------
[ Upstream commit 10442994ba195efef6fdcc0c3699e4633cb5161b ]
Right now we're never calling get_signal() from PF_IO_WORKER threads, but in preparation for doing so, don't handle a fatal signal for them. The workers have state they need to cleanup when exiting, so just return instead of calling do_exit() on their behalf. The threads themselves will detect a fatal signal and do proper shutdown.
Signed-off-by: Jens Axboe axboe@kernel.dk Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- kernel/signal.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/signal.c b/kernel/signal.c index cda7e1ed7884..185acbaece46 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2760,6 +2760,14 @@ bool get_signal(struct ksignal *ksig) do_coredump(&ksig->info); }
+ /* + * PF_IO_WORKER threads will catch and exit on fatal signals + * themselves. They have cleanup that must be performed, so + * we cannot call do_exit() on their behalf. + */ + if (current->flags & PF_IO_WORKER) + goto out; + /* * Death signals, no core dump. */ @@ -2767,7 +2775,7 @@ bool get_signal(struct ksignal *ksig) /* NOTREACHED */ } spin_unlock_irq(&sighand->siglock); - +out: ksig->sig = signr; return ksig->sig > 0; }