]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 20 Oct 2021 17:43:52 +0000 (12:43 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Mon, 25 Oct 2021 20:56:29 +0000 (15:56 -0500)
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: 0ea820cf9bf5 ("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>
arch/sh/kernel/cpu/fpu.c

index ae354a2931e7e17eec6e375c1d5add9ed0dcc54b..fd6db0ab19288f42fcdd6c6055c54a3a80f1d68a 100644 (file)
@@ -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);