Skip to content

Commit

Permalink
signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: [email protected]
Fixes: 0ea820c ("sh: Move over to dynamically allocated FPU context.")
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Eric W. Biederman <[email protected]>
  • Loading branch information
ebiederm committed Oct 25, 2021
1 parent 95bf9d6 commit ce0ee4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions arch/sh/kernel/cpu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ void fpu_state_restore(struct pt_regs *regs)
}

if (!tsk_used_math(tsk)) {
local_irq_enable();
int ret;
/*
* does a slab alloc which can sleep
*/
if (init_fpu(tsk)) {
local_irq_enable();
ret = init_fpu(tsk);
local_irq_disable();
if (ret) {
/*
* ran out of memory!
*/
do_group_exit(SIGKILL);
force_sig(SIGKILL);
return;
}
local_irq_disable();
}

grab_fpu(regs);
Expand Down

0 comments on commit ce0ee4e

Please sign in to comment.