From e844bfa2c53c6f4ad0c2d3eb7c473792a367387c Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 12 Dec 2023 07:37:22 +0000 Subject: The sigtramp was calling sigreturn(2), and upon failure exit(2), which doesn't make sense anymore. It is better to just issue an illegal instruction. ok kettenis, with some misgivings about inconsistant approaches between architectures. In the future we could change sigreturn(2) to never return an exit code, but always just terminate the process. We stopped this system call from being callable ages ago with msyscall(2), and there is no stub for it in libc.. maybe that's the next step to take? --- sys/arch/amd64/amd64/locore.S | 7 ++----- sys/arch/arm/arm/sigcode.S | 9 ++------- sys/arch/arm64/arm64/locore.S | 10 ++-------- sys/arch/hppa/hppa/locore.S | 11 +++-------- sys/arch/i386/i386/locore.s | 6 ++---- sys/arch/m88k/m88k/subr.S | 12 ++---------- sys/arch/macppc/macppc/locore.S | 6 ++---- sys/arch/mips64/mips64/lcore_access.S | 6 ++---- sys/arch/powerpc64/powerpc64/locore.S | 6 ++---- sys/arch/riscv64/riscv64/locore.S | 24 +++++++++++------------- sys/arch/sh/sh/locore_subr.S | 8 +++----- sys/arch/sparc64/sparc64/locore.s | 6 ++---- 12 files changed, 35 insertions(+), 76 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index a3d496e44e1..b36ab19d853 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.142 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.143 2023/12/12 07:37:20 deraadt Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -181,13 +181,10 @@ sigcodecall: syscall .globl sigcoderet sigcoderet: - movq $SYS_exit,%rax - syscall - _ALIGN_TRAPS + int3 1: JMP_RETPOLINE(rax) .globl esigcode esigcode: - .globl sigfill sigfill: int3 diff --git a/sys/arch/arm/arm/sigcode.S b/sys/arch/arm/arm/sigcode.S index 70c0f54750e..b2402d8c1a1 100644 --- a/sys/arch/arm/arm/sigcode.S +++ b/sys/arch/arm/arm/sigcode.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigcode.S,v 1.13 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: sigcode.S,v 1.14 2023/12/12 07:37:20 deraadt Exp $ */ /* $NetBSD: sigcode.S,v 1.6 2003/10/05 19:44:58 matt Exp $ */ /* @@ -63,14 +63,9 @@ sigcodecall: isb .globl sigcoderet sigcoderet: - /* Well if that failed we better exit quick ! */ - mov r12, #SYS_exit - swi 0 - dsb nsh - isb .global esigcode esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: udf #0 diff --git a/sys/arch/arm64/arm64/locore.S b/sys/arch/arm64/arm64/locore.S index 9f2faa0d213..771e7eff786 100644 --- a/sys/arch/arm64/arm64/locore.S +++ b/sys/arch/arm64/arm64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.44 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.45 2023/12/12 07:37:20 deraadt Exp $ */ /*- * Copyright (c) 2012-2014 Andrew Turner * All rights reserved. @@ -372,16 +372,10 @@ sigcodecall: isb .globl sigcoderet sigcoderet: - - /* sigreturn failed, exit */ - mov x8, #SYS_exit - svc 0 - dsb nsh - isb END(sigcode) .global esigcode esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: udf #0 diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S index 28647e5f426..3c952c8bf1d 100644 --- a/sys/arch/hppa/hppa/locore.S +++ b/sys/arch/hppa/hppa/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.206 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.207 2023/12/12 07:37:20 deraadt Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -2872,15 +2872,10 @@ sigcodecall: ldi SYS_sigreturn, t1 .globl sigcoderet sigcoderet: - - ldil L%SYSCALLGATE, r1 - copy ret0, arg0 - .call - ble 4(sr7, r1) - ldi SYS_exit, t1 + break 0,0 ALTENTRY(esigcode) -EXIT(sigcode) +EXIT(sigcode) .globl sigfill sigfill: break 0,0 diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index c3a749702a3..b25acfaab5c 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.203 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.204 2023/12/12 07:37:20 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -346,11 +346,9 @@ sigcodecall: int $0x80 # enter kernel with args on stack .globl sigcoderet sigcoderet: - movl $SYS_exit,%eax - int $0x80 # exit if sigreturn fails .globl esigcode esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: int3 diff --git a/sys/arch/m88k/m88k/subr.S b/sys/arch/m88k/m88k/subr.S index 69d79fe859d..ff73eec1553 100644 --- a/sys/arch/m88k/m88k/subr.S +++ b/sys/arch/m88k/m88k/subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: subr.S,v 1.30 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: subr.S,v 1.31 2023/12/12 07:37:21 deraadt Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1992 Carnegie Mellon University @@ -1138,16 +1138,8 @@ GLOBAL(sigcoderet) #ifdef dontbother /* sigreturn will not return unless it fails */ NOP | success return #endif - or %r13, %r0, SYS_exit - tb0 0, %r0, 450 /* syscall trap, exit */ - /* - * this never returns, but we need to provide fetchable instructions - * for the 88100 pipeline. - */ - NOP - NOP GLOBAL(esigcode) - + /* FALLTHROUGH */ GLOBAL(sigfill) tb0 0, %r0, 130 /* breakpoint */ GLOBAL(sigfillsiz) diff --git a/sys/arch/macppc/macppc/locore.S b/sys/arch/macppc/macppc/locore.S index 76ed02fcee5..d1c59bf5979 100644 --- a/sys/arch/macppc/macppc/locore.S +++ b/sys/arch/macppc/macppc/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.63 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.64 2023/12/12 07:37:21 deraadt Exp $ */ /* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */ /* @@ -1180,10 +1180,8 @@ sigcodecall: sc /* sigreturn(scp) */ .globl sigcoderet sigcoderet: - li %r0,SYS_exit - sc /* exit(errno) */ esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: .long 0 # illegal diff --git a/sys/arch/mips64/mips64/lcore_access.S b/sys/arch/mips64/mips64/lcore_access.S index f2106d14ef3..1aeb6c26fa8 100644 --- a/sys/arch/mips64/mips64/lcore_access.S +++ b/sys/arch/mips64/mips64/lcore_access.S @@ -1,4 +1,4 @@ -/* $OpenBSD: lcore_access.S,v 1.35 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: lcore_access.S,v 1.36 2023/12/12 07:37:21 deraadt Exp $ */ /* * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -80,11 +80,9 @@ sigcodecall: syscall .globl sigcoderet sigcoderet: - LI v0, SYS_exit # just in case sigreturn fails - syscall .globl esigcode esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: teq zero, zero, 0x52 diff --git a/sys/arch/powerpc64/powerpc64/locore.S b/sys/arch/powerpc64/powerpc64/locore.S index c74b185651c..59c5cb5d2f8 100644 --- a/sys/arch/powerpc64/powerpc64/locore.S +++ b/sys/arch/powerpc64/powerpc64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.47 2023/12/10 16:56:01 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.48 2023/12/12 07:37:21 deraadt Exp $ */ /* * Copyright (c) 2020 Mark Kettenis @@ -42,11 +42,9 @@ sigcodecall: sc .globl sigcoderet sigcoderet: - li %r0, SYS_exit - sc .globl esigcode esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: .long 0 diff --git a/sys/arch/riscv64/riscv64/locore.S b/sys/arch/riscv64/riscv64/locore.S index f1f1f2e8be7..f7c3f0f01c5 100644 --- a/sys/arch/riscv64/riscv64/locore.S +++ b/sys/arch/riscv64/riscv64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.16 2023/12/10 16:56:02 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.17 2023/12/12 07:37:21 deraadt Exp $ */ /*- * Copyright (c) 2015-2018 Ruslan Bukin @@ -236,15 +236,6 @@ initstack: .space USPACE initstack_end: - .globl sigfill -sigfill: - unimp -esigfill: - .globl sigfillsiz -sigfillsiz: - .data - .word esigfill - sigfill - .text ENTRY(sigcode) mv a0, sp @@ -255,13 +246,20 @@ sigcodecall: ecall .globl sigcoderet sigcoderet: - /* sigreturn failed, exit */ - li t0, SYS_exit - ecall + unimp END(sigcode) .globl esigcode esigcode: + .globl sigfill +sigfill: + unimp +esigfill: + .globl sigfillsiz +sigfillsiz: + .data + .word esigfill - sigfill + .data .global esym esym: diff --git a/sys/arch/sh/sh/locore_subr.S b/sys/arch/sh/sh/locore_subr.S index 2bd371ff887..944d1d2372e 100644 --- a/sys/arch/sh/sh/locore_subr.S +++ b/sys/arch/sh/sh/locore_subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore_subr.S,v 1.18 2023/12/10 16:56:02 deraadt Exp $ */ +/* $OpenBSD: locore_subr.S,v 1.19 2023/12/12 07:37:21 deraadt Exp $ */ /* $NetBSD: locore_subr.S,v 1.28 2006/01/23 22:52:09 uwe Exp $ */ /* @@ -45,7 +45,7 @@ #include "assym.h" -#include /* SYS_sigreturn, SYS_exit */ +#include /* SYS_sigreturn */ #include #include #include /* UPAGES */ @@ -502,13 +502,11 @@ sigcodecall: trapa #0x80 /* and call sigreturn() */ .globl sigcoderet sigcoderet: - mov.l .L_SYS_exit, r0 - trapa #0x80 /* exit if sigreturn fails */ + sleep /* privileged -> illegal? */ /* NOTREACHED */ .align 2 .L_SYS_sigreturn: .long SYS_sigreturn -.L_SYS_exit: .long SYS_exit /* LINTSTUB: Var: char esigcode[1] */ .globl esigcode diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s index 786bb4a7ace..a92c987562d 100644 --- a/sys/arch/sparc64/sparc64/locore.s +++ b/sys/arch/sparc64/sparc64/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.203 2023/12/10 16:56:02 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.204 2023/12/12 07:37:21 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.137 2001/08/13 06:10:10 jdolecek Exp $ */ /* @@ -5403,11 +5403,9 @@ sigcoderet: sigcodecall: t ST_SYSCALL ! sigreturn(scp) ! sigreturn does not return unless it fails - mov SYS_exit, %g1 ! exit(errno) - t ST_SYSCALL .globl esigcode esigcode: - + /* FALLTHROUGH */ .globl sigfill sigfill: unimp -- cgit v1.2.3