Skip to content

Commit a4cbf00

Browse files
ebiedermgregkh
authored andcommitted
signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)
[ Upstream commit ce0ee4e ] Today the sh code allocates memory the first time a process uses the fpu. If that memory allocation fails, kill the affected task with force_sig(SIGKILL) rather than do_group_exit(SIGKILL). Calling do_group_exit from an exception handler can potentially lead to dead locks as do_group_exit is not designed to be called from interrupt context. Instead use force_sig(SIGKILL) to kill the userspace process. Sending signals in general and force_sig in particular has been tested from interrupt context so there should be no problems. Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Rich Felker <dalias@libc.org> Cc: linux-sh@vger.kernel.org Fixes: 0ea820c ("sh: Move over to dynamically allocated FPU context.") Link: https://lkml.kernel.org/r/20211020174406.17889-6-ebiederm@xmission.com Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b04c17a commit a4cbf00

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎arch/sh/kernel/cpu/fpu.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,20 @@ void fpu_state_restore(struct pt_regs *regs)
6262
}
6363

6464
if (!tsk_used_math(tsk)) {
65-
local_irq_enable();
65+
int ret;
6666
/*
6767
* does a slab alloc which can sleep
6868
*/
69-
if (init_fpu(tsk)) {
69+
local_irq_enable();
70+
ret = init_fpu(tsk);
71+
local_irq_disable();
72+
if (ret) {
7073
/*
7174
* ran out of memory!
7275
*/
73-
do_group_exit(SIGKILL);
76+
force_sig(SIGKILL);
7477
return;
7578
}
76-
local_irq_disable();
7779
}
7880

7981
grab_fpu(regs);

0 commit comments

Comments
 (0)