* [PATCH 00/20] exit cleanups
@ 2021-10-20 17:32 Eric W. Biederman
2021-10-20 17:43 ` [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT Eric W. Biederman
2021-10-20 21:51 ` [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) Eric W. Biederman
0 siblings, 2 replies; 10+ messages in thread
From: Eric W. Biederman @ 2021-10-20 17:32 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro, Kees Cook,
Andy Lutomirski, Jonas Bonn, Stefan Kristiansson, Stafford Horne,
openrisc, Nick Hu, Greentime Hu, Vincent Chen, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, linux-s390, Yoshinori Sato,
Rich Felker, linux-sh, linux-xtensa, Chris Zankel, Max Filippov,
David Miller, sparclinux, Thomas Bogendoerfer, Maciej Rozycki,
linux-mips, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, linuxppc-dev, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H Peter Anvin, Greg Kroah-Hartman
While looking at some issues related to the exit path in the kernel I
found several instances where the code is not using the existing
abstractions properly.
This set of changes introduces force_fatal_sig a way of sending
a signal and not allowing it to be caught, and corrects the
misuse of the existing abstractions that I found.
A lot of the misuse of the existing abstractions are silly things such
as doing something after calling a no return function, rolling BUG by
hand, doing more work than necessary to terminate a kernel thread, or
calling do_exit(SIGKILL) instead of calling force_sig(SIGKILL).
It is my plan after sending all of these changes out for review to place
them in a topic branch for sending Linus. Especially for the changes
that depend upon the new helper force_fatal_sig this is important.
Eric W. Biederman (20):
exit/doublefault: Remove apparently bogus comment about rewind_stack_do_exit
exit: Remove calls of do_exit after noreturn versions of die
reboot: Remove the unreachable panic after do_exit in reboot(2)
signal/sparc32: Remove unreachable do_exit in do_sparc_fault
signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)
signal/powerpc: On swapcontext failure force SIGSEGV
signal/sparc: In setup_tsb_params convert open coded BUG into BUG
signal/vm86_32: Replace open coded BUG_ON with an actual BUG_ON
signal/vm86_32: Properly send SIGSEGV when the vm86 state cannot be saved.
signal/s390: Use force_sigsegv in default_trap_handler
exit/kthread: Have kernel threads return instead of calling do_exit
signal: Implement force_fatal_sig
exit/syscall_user_dispatch: Send ordinary signals on failure
signal/sparc32: Exit with a fatal signal when try_to_clear_window_buffer fails
signal/sparc32: In setup_rt_frame and setup_fram use force_fatal_sig
signal/x86: In emulate_vsyscall force a signal instead of calling do_exit
exit/rtl8723bs: Replace the macro thread_exit with a simple return 0
exit/rtl8712: Replace the macro thread_exit with a simple return 0
exit/r8188eu: Replace the macro thread_exit with a simple return 0
arch/mips/kernel/r2300_fpu.S | 4 ++--
arch/mips/kernel/syscall.c | 9 --------
arch/nds32/kernel/traps.c | 2 +-
arch/nds32/mm/fault.c | 6 +----
arch/openrisc/kernel/traps.c | 2 +-
arch/openrisc/mm/fault.c | 4 +---
arch/powerpc/kernel/signal_32.c | 6 +++--
arch/powerpc/kernel/signal_64.c | 9 +++++---
arch/s390/include/asm/kdebug.h | 2 +-
arch/s390/kernel/dumpstack.c | 2 +-
arch/s390/kernel/traps.c | 2 +-
arch/s390/mm/fault.c | 2 --
arch/sh/kernel/cpu/fpu.c | 10 +++++----
arch/sh/kernel/traps.c | 2 +-
arch/sh/mm/fault.c | 2 --
arch/sparc/kernel/signal_32.c | 4 ++--
arch/sparc/kernel/windows.c | 6 +++--
arch/sparc/mm/fault_32.c | 1 -
arch/sparc/mm/tsb.c | 2 +-
arch/x86/entry/vsyscall/vsyscall_64.c | 3 ++-
arch/x86/kernel/doublefault_32.c | 3 ---
arch/x86/kernel/signal.c | 6 ++++-
arch/x86/kernel/vm86_32.c | 8 +++----
arch/xtensa/kernel/traps.c | 2 +-
arch/xtensa/mm/fault.c | 3 +--
drivers/firmware/stratix10-svc.c | 4 ++--
drivers/soc/ti/wkup_m3_ipc.c | 2 +-
drivers/staging/r8188eu/core/rtw_cmd.c | 2 +-
drivers/staging/r8188eu/core/rtw_mp.c | 2 +-
drivers/staging/r8188eu/include/osdep_service.h | 2 --
drivers/staging/rtl8712/osdep_service.h | 1 -
drivers/staging/rtl8712/rtl8712_cmd.c | 2 +-
drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +-
drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +-
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 2 +-
.../rtl8723bs/include/osdep_service_linux.h | 2 --
fs/ocfs2/journal.c | 5 +----
include/linux/sched/signal.h | 1 +
kernel/entry/syscall_user_dispatch.c | 12 ++++++----
kernel/kthread.c | 2 +-
kernel/reboot.c | 1 -
kernel/signal.c | 26 ++++++++++++++--------
net/batman-adv/tp_meter.c | 2 +-
43 files changed, 83 insertions(+), 91 deletions(-)
Eric
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
2021-10-20 17:32 [PATCH 00/20] exit cleanups Eric W. Biederman
@ 2021-10-20 17:43 ` Eric W. Biederman
2021-10-21 16:06 ` Kees Cook
` (2 more replies)
2021-10-20 21:51 ` [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) Eric W. Biederman
1 sibling, 3 replies; 10+ messages in thread
From: Eric W. Biederman @ 2021-10-20 17:43 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro, Kees Cook,
Eric W. Biederman, Thomas Bogendoerfer, Maciej Rozycki,
linux-mips
When an instruction to save or restore a register from the stack fails
in _save_fp_context or _restore_fp_context return with -EFAULT. This
change was made to r2300_fpu.S[1] but it looks like it got lost with
the introduction of EX2[2]. This is also what the other implementation
of _save_fp_context and _restore_fp_context in r4k_fpu.S does, and
what is needed for the callers to be able to handle the error.
Furthermore calling do_exit(SIGSEGV) from bad_stack is wrong because
it does not terminate the entire process it just terminates a single
thread.
As the changed code was the only caller of arch/mips/kernel/syscall.c:bad_stack
remove the problematic and now unused helper function.
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Maciej Rozycki <macro@orcam.me.uk>
Cc: linux-mips@vger.kernel.org
[1] 35938a00ba86 ("MIPS: Fix ISA I FP sigcontext access violation handling")
[2] f92722dc4545 ("MIPS: Correct MIPS I FP sigcontext layout")
Fixes: f92722dc4545 ("MIPS: Correct MIPS I FP sigcontext layout")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
arch/mips/kernel/r2300_fpu.S | 4 ++--
arch/mips/kernel/syscall.c | 9 ---------
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/arch/mips/kernel/r2300_fpu.S b/arch/mips/kernel/r2300_fpu.S
index 12e58053544f..cbf6db98cfb3 100644
--- a/arch/mips/kernel/r2300_fpu.S
+++ b/arch/mips/kernel/r2300_fpu.S
@@ -29,8 +29,8 @@
#define EX2(a,b) \
9: a,##b; \
.section __ex_table,"a"; \
- PTR 9b,bad_stack; \
- PTR 9b+4,bad_stack; \
+ PTR 9b,fault; \
+ PTR 9b+4,fault; \
.previous
.set mips1
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 2afa3eef486a..5512cd586e6e 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -240,12 +240,3 @@ SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op)
{
return -ENOSYS;
}
-
-/*
- * If we ever come here the user sp is bad. Zap the process right away.
- * Due to the bad stack signaling wouldn't work.
- */
-asmlinkage void bad_stack(void)
-{
- do_exit(SIGSEGV);
-}
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV)
2021-10-20 17:32 [PATCH 00/20] exit cleanups Eric W. Biederman
2021-10-20 17:43 ` [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT Eric W. Biederman
@ 2021-10-20 21:51 ` Eric W. Biederman
2021-10-21 8:09 ` Geert Uytterhoeven
2021-10-21 8:32 ` Philippe Mathieu-Daudé
1 sibling, 2 replies; 10+ messages in thread
From: Eric W. Biederman @ 2021-10-20 21:51 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro, Kees Cook,
Andy Lutomirski, Jonas Bonn, Stefan Kristiansson, Stafford Horne,
openrisc, Nick Hu, Greentime Hu, Vincent Chen, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, linux-s390, Yoshinori Sato,
Rich Felker, linux-sh, linux-xtensa, Chris Zankel, Max Filippov,
David Miller, sparclinux, Thomas Bogendoerfer, Maciej Rozycki,
linux-mips, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, linuxppc-dev, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H Peter Anvin, Greg Kroah-Hartman
Now that force_fatal_sig exists it is unnecessary and a bit confusing
to use force_sigsegv in cases where the simpler force_fatal_sig is
wanted. So change every instance we can to make the code clearer.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
arch/arc/kernel/process.c | 2 +-
arch/m68k/kernel/traps.c | 2 +-
arch/powerpc/kernel/signal_32.c | 2 +-
arch/powerpc/kernel/signal_64.c | 4 ++--
arch/s390/kernel/traps.c | 2 +-
arch/um/kernel/trap.c | 2 +-
arch/x86/kernel/vm86_32.c | 2 +-
fs/exec.c | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index 3793876f42d9..8e90052f6f05 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -294,7 +294,7 @@ int elf_check_arch(const struct elf32_hdr *x)
eflags = x->e_flags;
if ((eflags & EF_ARC_OSABI_MSK) != EF_ARC_OSABI_CURRENT) {
pr_err("ABI mismatch - you need newer toolchain\n");
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
return 0;
}
diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c
index 5b19fcdcd69e..74045d164ddb 100644
--- a/arch/m68k/kernel/traps.c
+++ b/arch/m68k/kernel/traps.c
@@ -1150,7 +1150,7 @@ asmlinkage void set_esp0(unsigned long ssp)
*/
asmlinkage void fpsp040_die(void)
{
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
}
#ifdef CONFIG_M68KFPU_EMU
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 666f3da41232..933ab95805a6 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -1063,7 +1063,7 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
* We kill the task with a SIGSEGV in this situation.
*/
if (do_setcontext(new_ctx, regs, 0)) {
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
return -EFAULT;
}
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index d8de622c9e4a..8ead9b3f47c6 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -704,7 +704,7 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
*/
if (__get_user_sigset(&set, &new_ctx->uc_sigmask)) {
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
return -EFAULT;
}
set_current_blocked(&set);
@@ -713,7 +713,7 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
return -EFAULT;
if (__unsafe_restore_sigcontext(current, NULL, 0, &new_ctx->uc_mcontext)) {
user_read_access_end();
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
return -EFAULT;
}
user_read_access_end();
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 51729ea2cf8e..01a7c68dcfb6 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -84,7 +84,7 @@ static void default_trap_handler(struct pt_regs *regs)
{
if (user_mode(regs)) {
report_user_fault(regs, SIGSEGV, 0);
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
} else
die(regs, "Unknown program exception");
}
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 3198c4767387..c32efb09db21 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -158,7 +158,7 @@ static void bad_segv(struct faultinfo fi, unsigned long ip)
void fatal_sigsegv(void)
{
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
do_signal(¤t->thread.regs);
/*
* This is to tell gcc that we're not returning - do_signal
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index 040fd01be8b3..7ff0f622abd4 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -159,7 +159,7 @@ void save_v86_state(struct kernel_vm86_regs *regs, int retval)
user_access_end();
Efault:
pr_alert("could not access userspace vm86 info\n");
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
}
static int do_vm86_irq_handling(int subfunction, int irqnumber);
diff --git a/fs/exec.c b/fs/exec.c
index a098c133d8d7..ac7b51b51f38 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1852,7 +1852,7 @@ static int bprm_execve(struct linux_binprm *bprm,
* SIGSEGV.
*/
if (bprm->point_of_no_return && !fatal_signal_pending(current))
- force_sigsegv(SIGSEGV);
+ force_fatal_sig(SIGSEGV);
out_unmark:
current->fs->in_exec = 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV)
2021-10-20 21:51 ` [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) Eric W. Biederman
@ 2021-10-21 8:09 ` Geert Uytterhoeven
2021-10-21 13:33 ` Eric W. Biederman
2021-10-21 8:32 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2021-10-21 8:09 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Linux Kernel Mailing List, Rich Felker,
open list:TENSILICA XTENSA PORT (xtensa), Benjamin Herrenschmidt,
open list:BROADCOM NVRAM DRIVER, Max Filippov, Paul Mackerras,
H Peter Anvin, sparclinux, Vincent Chen, Thomas Gleixner,
Linux-Arch, linux-s390, Yoshinori Sato, Michael Ellerman,
Linux-sh list, Christian Borntraeger, Ingo Molnar, Jonas Bonn,
Kees Cook, Vasily Gorbik, Heiko Carstens, Openrisc,
Borislav Petkov, Al Viro, Andy Lutomirski, Chris Zankel,
Thomas Bogendoerfer, Nick Hu, linuxppc-dev, Oleg Nesterov,
Greg Kroah-Hartman, Maciej Rozycki, Linus Torvalds, David Miller,
Greentime Hu
Hi Eric,
Patch 21/20?
On Wed, Oct 20, 2021 at 11:52 PM Eric W. Biederman
<ebiederm@xmission.com> wrote:
> Now that force_fatal_sig exists it is unnecessary and a bit confusing
> to use force_sigsegv in cases where the simpler force_fatal_sig is
> wanted. So change every instance we can to make the code clearer.
>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> arch/m68k/kernel/traps.c | 2 +-
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV)
2021-10-20 21:51 ` [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) Eric W. Biederman
2021-10-21 8:09 ` Geert Uytterhoeven
@ 2021-10-21 8:32 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-21 8:32 UTC (permalink / raw)
To: Eric W. Biederman
Cc: open list, linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro,
Kees Cook, Andy Lutomirski, Jonas Bonn, Stefan Kristiansson,
Stafford Horne, openrisc, Nick Hu, Greentime Hu, Vincent Chen,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger, linux-s390,
Yoshinori Sato, Rich Felker, linux-sh, linux-xtensa, Chris Zankel,
Max Filippov, David Miller, sparclinux, Thomas Bogendoerfer,
Maciej Rozycki, open list:BROADCOM NVRAM DRIVER, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, H Peter Anvin,
Greg Kroah-Hartman
On Wed, Oct 20, 2021 at 11:52 PM Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
>
> Now that force_fatal_sig exists it is unnecessary and a bit confusing
> to use force_sigsegv in cases where the simpler force_fatal_sig is
> wanted. So change every instance we can to make the code clearer.
>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
> arch/arc/kernel/process.c | 2 +-
> arch/m68k/kernel/traps.c | 2 +-
> arch/powerpc/kernel/signal_32.c | 2 +-
> arch/powerpc/kernel/signal_64.c | 4 ++--
> arch/s390/kernel/traps.c | 2 +-
> arch/um/kernel/trap.c | 2 +-
> arch/x86/kernel/vm86_32.c | 2 +-
> fs/exec.c | 2 +-
> 8 files changed, 9 insertions(+), 9 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV)
2021-10-21 8:09 ` Geert Uytterhoeven
@ 2021-10-21 13:33 ` Eric W. Biederman
0 siblings, 0 replies; 10+ messages in thread
From: Eric W. Biederman @ 2021-10-21 13:33 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linux Kernel Mailing List, Rich Felker,
open list:TENSILICA XTENSA PORT (xtensa), Benjamin Herrenschmidt,
open list:BROADCOM NVRAM DRIVER, Max Filippov, Paul Mackerras,
H Peter Anvin, sparclinux, Vincent Chen, Thomas Gleixner,
Linux-Arch, linux-s390, Yoshinori Sato, Michael Ellerman,
Linux-sh list, Christian Borntraeger, Ingo Molnar, Jonas Bonn,
Kees Cook, Vasily Gorbik, Heiko Carstens, Openrisc,
Borislav Petkov, Al Viro, Andy Lutomirski, Chris Zankel,
Thomas Bogendoerfer, Nick Hu, linuxppc-dev, Oleg Nesterov,
Greg Kroah-Hartman, Maciej Rozycki, Linus Torvalds, David Miller,
Greentime Hu
Geert Uytterhoeven <geert@linux-m68k.org> writes:
> Hi Eric,
>
> Patch 21/20?
In reviewing another part of the patchset Linus asked if force_sigsegv
could go away. It can't completely but I can get this far.
Given that it is just a cleanup it makes most sense to me as an
additional patch on top of what is already here.
> On Wed, Oct 20, 2021 at 11:52 PM Eric W. Biederman
> <ebiederm@xmission.com> wrote:
>> Now that force_fatal_sig exists it is unnecessary and a bit confusing
>> to use force_sigsegv in cases where the simpler force_fatal_sig is
>> wanted. So change every instance we can to make the code clearer.
>>
>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>
>> arch/m68k/kernel/traps.c | 2 +-
>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Thank you.
Eric
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
2021-10-20 17:43 ` [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT Eric W. Biederman
@ 2021-10-21 16:06 ` Kees Cook
2021-10-24 4:24 ` Maciej W. Rozycki
2021-10-24 15:27 ` Thomas Bogendoerfer
2 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2021-10-21 16:06 UTC (permalink / raw)
To: Eric W. Biederman
Cc: linux-kernel, linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro,
Thomas Bogendoerfer, Maciej Rozycki, linux-mips
On Wed, Oct 20, 2021 at 12:43:51PM -0500, Eric W. Biederman wrote:
> When an instruction to save or restore a register from the stack fails
> in _save_fp_context or _restore_fp_context return with -EFAULT. This
> change was made to r2300_fpu.S[1] but it looks like it got lost with
> the introduction of EX2[2]. This is also what the other implementation
> of _save_fp_context and _restore_fp_context in r4k_fpu.S does, and
> what is needed for the callers to be able to handle the error.
>
> Furthermore calling do_exit(SIGSEGV) from bad_stack is wrong because
> it does not terminate the entire process it just terminates a single
> thread.
>
> As the changed code was the only caller of arch/mips/kernel/syscall.c:bad_stack
> remove the problematic and now unused helper function.
>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Maciej Rozycki <macro@orcam.me.uk>
> Cc: linux-mips@vger.kernel.org
> [1] 35938a00ba86 ("MIPS: Fix ISA I FP sigcontext access violation handling")
> [2] f92722dc4545 ("MIPS: Correct MIPS I FP sigcontext layout")
> Fixes: f92722dc4545 ("MIPS: Correct MIPS I FP sigcontext layout")
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
2021-10-20 17:43 ` [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT Eric W. Biederman
2021-10-21 16:06 ` Kees Cook
@ 2021-10-24 4:24 ` Maciej W. Rozycki
2021-10-25 20:55 ` Eric W. Biederman
2021-10-24 15:27 ` Thomas Bogendoerfer
2 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2021-10-24 4:24 UTC (permalink / raw)
To: Eric W. Biederman
Cc: linux-kernel, linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro,
Kees Cook, Thomas Bogendoerfer, linux-mips
On Wed, 20 Oct 2021, Eric W. Biederman wrote:
> When an instruction to save or restore a register from the stack fails
> in _save_fp_context or _restore_fp_context return with -EFAULT. This
> change was made to r2300_fpu.S[1] but it looks like it got lost with
> the introduction of EX2[2]. This is also what the other implementation
> of _save_fp_context and _restore_fp_context in r4k_fpu.S does, and
> what is needed for the callers to be able to handle the error.
Umm, right, good catch, thanks! I think this ought to be backported.
Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
Maciej
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
2021-10-20 17:43 ` [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT Eric W. Biederman
2021-10-21 16:06 ` Kees Cook
2021-10-24 4:24 ` Maciej W. Rozycki
@ 2021-10-24 15:27 ` Thomas Bogendoerfer
2 siblings, 0 replies; 10+ messages in thread
From: Thomas Bogendoerfer @ 2021-10-24 15:27 UTC (permalink / raw)
To: Eric W. Biederman
Cc: linux-kernel, linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro,
Kees Cook, Maciej Rozycki, linux-mips
On Wed, Oct 20, 2021 at 12:43:51PM -0500, Eric W. Biederman wrote:
> When an instruction to save or restore a register from the stack fails
> in _save_fp_context or _restore_fp_context return with -EFAULT. This
> change was made to r2300_fpu.S[1] but it looks like it got lost with
> the introduction of EX2[2]. This is also what the other implementation
> of _save_fp_context and _restore_fp_context in r4k_fpu.S does, and
> what is needed for the callers to be able to handle the error.
>
> Furthermore calling do_exit(SIGSEGV) from bad_stack is wrong because
> it does not terminate the entire process it just terminates a single
> thread.
>
> As the changed code was the only caller of arch/mips/kernel/syscall.c:bad_stack
> remove the problematic and now unused helper function.
>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Maciej Rozycki <macro@orcam.me.uk>
> Cc: linux-mips@vger.kernel.org
> [1] 35938a00ba86 ("MIPS: Fix ISA I FP sigcontext access violation handling")
> [2] f92722dc4545 ("MIPS: Correct MIPS I FP sigcontext layout")
> Fixes: f92722dc4545 ("MIPS: Correct MIPS I FP sigcontext layout")
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
> arch/mips/kernel/r2300_fpu.S | 4 ++--
> arch/mips/kernel/syscall.c | 9 ---------
> 2 files changed, 2 insertions(+), 11 deletions(-)
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
2021-10-24 4:24 ` Maciej W. Rozycki
@ 2021-10-25 20:55 ` Eric W. Biederman
0 siblings, 0 replies; 10+ messages in thread
From: Eric W. Biederman @ 2021-10-25 20:55 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: linux-kernel, linux-arch, Linus Torvalds, Oleg Nesterov, Al Viro,
Kees Cook, Thomas Bogendoerfer, linux-mips
"Maciej W. Rozycki" <macro@orcam.me.uk> writes:
> On Wed, 20 Oct 2021, Eric W. Biederman wrote:
>
>> When an instruction to save or restore a register from the stack fails
>> in _save_fp_context or _restore_fp_context return with -EFAULT. This
>> change was made to r2300_fpu.S[1] but it looks like it got lost with
>> the introduction of EX2[2]. This is also what the other implementation
>> of _save_fp_context and _restore_fp_context in r4k_fpu.S does, and
>> what is needed for the callers to be able to handle the error.
>
> Umm, right, good catch, thanks! I think this ought to be backported.
>
> Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
>
I will add a CC stable. So it can be backported after it is merged.
Eric
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-10-25 20:55 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-20 17:32 [PATCH 00/20] exit cleanups Eric W. Biederman
2021-10-20 17:43 ` [PATCH 05/20] signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT Eric W. Biederman
2021-10-21 16:06 ` Kees Cook
2021-10-24 4:24 ` Maciej W. Rozycki
2021-10-25 20:55 ` Eric W. Biederman
2021-10-24 15:27 ` Thomas Bogendoerfer
2021-10-20 21:51 ` [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) Eric W. Biederman
2021-10-21 8:09 ` Geert Uytterhoeven
2021-10-21 13:33 ` Eric W. Biederman
2021-10-21 8:32 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).