From: deraadt Date: Sun, 10 Dec 2023 16:56:01 +0000 (+0000) Subject: Add a new label "sigcodecall" inside every sigtramp definition, directly X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=20cef513d8ab5a7a4c3f2af5c0d1615fb674c6d0;p=openbsd Add a new label "sigcodecall" inside every sigtramp definition, directly in front of the syscall instruction. This is used to calculate the start of the syscall for SYS_sigreturn and pinned system calls. ok kettenis --- diff --git a/sys/arch/alpha/alpha/locore.s b/sys/arch/alpha/alpha/locore.s index 1bbf06a512a..6b5f09767de 100644 --- a/sys/arch/alpha/alpha/locore.s +++ b/sys/arch/alpha/alpha/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.53 2023/12/06 06:15:33 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.54 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.94 2001/04/26 03:10:44 ross Exp $ */ /*- @@ -202,6 +202,8 @@ NESTED(sigcode,0,0,ra,0,0) ldq a0, 0(sp) /* get the sigcontext pointer */ lda sp, 16(sp) ldiq v0, SYS_sigreturn /* and call sigreturn() with it. */ + .globl sigcodecall +sigcodecall: call_pal PAL_OSF1_callsys .globl sigcoderet sigcoderet: diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index bcf30f659bd..a3d496e44e1 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.141 2023/10/24 13:20:09 claudio Exp $ */ +/* $OpenBSD: locore.S,v 1.142 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -176,6 +176,8 @@ sigcode: movq %rsp,%rdi pushq %rdi /* fake return address */ movq $SYS_sigreturn,%rax + .globl sigcodecall +sigcodecall: syscall .globl sigcoderet sigcoderet: diff --git a/sys/arch/arm/arm/sigcode.S b/sys/arch/arm/arm/sigcode.S index a6a842df292..70c0f54750e 100644 --- a/sys/arch/arm/arm/sigcode.S +++ b/sys/arch/arm/arm/sigcode.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigcode.S,v 1.12 2022/12/08 01:25:44 guenther Exp $ */ +/* $OpenBSD: sigcode.S,v 1.13 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: sigcode.S,v 1.6 2003/10/05 19:44:58 matt Exp $ */ /* @@ -56,6 +56,8 @@ sigcode: /* mov r0, sp */ add r0, sp, #SIGF_SC mov r12, #SYS_sigreturn + .globl sigcodecall +sigcodecall: swi 0 dsb nsh isb diff --git a/sys/arch/arm64/arm64/locore.S b/sys/arch/arm64/arm64/locore.S index 057d2264e2d..9f2faa0d213 100644 --- a/sys/arch/arm64/arm64/locore.S +++ b/sys/arch/arm64/arm64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.43 2023/01/26 13:09:18 kettenis Exp $ */ +/* $OpenBSD: locore.S,v 1.44 2023/12/10 16:56:01 deraadt Exp $ */ /*- * Copyright (c) 2012-2014 Andrew Turner * All rights reserved. @@ -365,6 +365,8 @@ sigcode: add x0, x0, #SF_SC mov x8, #SYS_sigreturn + .globl sigcodecall +sigcodecall: svc 0 dsb nsh isb diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S index 068440760e1..28647e5f426 100644 --- a/sys/arch/hppa/hppa/locore.S +++ b/sys/arch/hppa/hppa/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.205 2023/10/24 13:20:10 claudio Exp $ */ +/* $OpenBSD: locore.S,v 1.206 2023/12/10 16:56:01 deraadt Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -2866,8 +2866,10 @@ sigcode_call ldil L%SYSCALLGATE, r1 copy r4, arg0 .call + .globl sigcodecall +sigcodecall: ble 4(sr7, r1) - ldi SYS_sigreturn, t1 + ldi SYS_sigreturn, t1 .globl sigcoderet sigcoderet: diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 2d80d10a7fb..c3a749702a3 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.202 2023/10/24 13:20:10 claudio Exp $ */ +/* $OpenBSD: locore.s,v 1.203 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -341,6 +341,8 @@ sigcode: pushl %eax pushl %eax # junk to fake return address movl $SYS_sigreturn,%eax + .globl sigcodecall +sigcodecall: int $0x80 # enter kernel with args on stack .globl sigcoderet sigcoderet: diff --git a/sys/arch/m88k/m88k/subr.S b/sys/arch/m88k/m88k/subr.S index c3e85883db1..69d79fe859d 100644 --- a/sys/arch/m88k/m88k/subr.S +++ b/sys/arch/m88k/m88k/subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: subr.S,v 1.29 2023/01/31 15:18:54 deraadt Exp $ */ +/* $OpenBSD: subr.S,v 1.30 2023/12/10 16:56:01 deraadt Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1992 Carnegie Mellon University @@ -1131,6 +1131,7 @@ ENTRY(longjmp) GLOBAL(sigcode) /* r31 points to sigframe */ ld %r2, %r31, 0 /* pick sigcontext* */ or %r13, %r0, SYS_sigreturn +GLOBAL(sigcodecall) GLOBAL(sigcoderet) tb0 0, %r0, 450 /* syscall trap, calling sigreturn */ NOP | failure return diff --git a/sys/arch/macppc/macppc/locore.S b/sys/arch/macppc/macppc/locore.S index c578d9a4a08..76ed02fcee5 100644 --- a/sys/arch/macppc/macppc/locore.S +++ b/sys/arch/macppc/macppc/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.62 2023/10/24 13:20:10 claudio Exp $ */ +/* $OpenBSD: locore.S,v 1.63 2023/12/10 16:56:01 deraadt Exp $ */ /* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */ /* @@ -1175,6 +1175,8 @@ sigcode: lfd %f13,104(%r6) addi %r3,%r1,((16+FPSIG_SIZEOF+15)&~0xf)+SF_SC /* compute &sf_sc */ li %r0,SYS_sigreturn + .globl sigcodecall +sigcodecall: sc /* sigreturn(scp) */ .globl sigcoderet sigcoderet: diff --git a/sys/arch/mips64/mips64/lcore_access.S b/sys/arch/mips64/mips64/lcore_access.S index bc51fe76cb4..f2106d14ef3 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.34 2023/01/31 15:18:55 deraadt Exp $ */ +/* $OpenBSD: lcore_access.S,v 1.35 2023/12/10 16:56:01 deraadt Exp $ */ /* * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -75,6 +75,8 @@ onfault_table: sigcode: PTR_ADDU a0, sp, 4*REGSZ # address of sigcontext LI v0, SYS_sigreturn # sigreturn(scp) + .globl sigcodecall +sigcodecall: syscall .globl sigcoderet sigcoderet: diff --git a/sys/arch/powerpc64/powerpc64/locore.S b/sys/arch/powerpc64/powerpc64/locore.S index d0a21c1d988..c74b185651c 100644 --- a/sys/arch/powerpc64/powerpc64/locore.S +++ b/sys/arch/powerpc64/powerpc64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.46 2023/10/24 13:20:10 claudio Exp $ */ +/* $OpenBSD: locore.S,v 1.47 2023/12/10 16:56:01 deraadt Exp $ */ /* * Copyright (c) 2020 Mark Kettenis @@ -31,14 +31,16 @@ .rodata .globl sigcode - .globl sigcoderet sigcode: addi %r1, %r1, -32 mtctr %r12 bctrl addi %r3, %r1, 32+SF_SC li %r0, SYS_sigreturn + .globl sigcodecall +sigcodecall: sc + .globl sigcoderet sigcoderet: li %r0, SYS_exit sc diff --git a/sys/arch/riscv64/riscv64/locore.S b/sys/arch/riscv64/riscv64/locore.S index 8848ac3bdf1..f1f1f2e8be7 100644 --- a/sys/arch/riscv64/riscv64/locore.S +++ b/sys/arch/riscv64/riscv64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.15 2022/12/02 12:27:08 jca Exp $ */ +/* $OpenBSD: locore.S,v 1.16 2023/12/10 16:56:02 deraadt Exp $ */ /*- * Copyright (c) 2015-2018 Ruslan Bukin @@ -250,8 +250,9 @@ ENTRY(sigcode) mv a0, sp addi a0, a0, SF_SC li t0, SYS_sigreturn + .globl sigcodecall +sigcodecall: ecall - .globl sigcoderet sigcoderet: /* sigreturn failed, exit */ diff --git a/sys/arch/sh/sh/locore_subr.S b/sys/arch/sh/sh/locore_subr.S index 342868128b0..2bd371ff887 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.17 2023/10/24 13:20:10 claudio Exp $ */ +/* $OpenBSD: locore_subr.S,v 1.18 2023/12/10 16:56:02 deraadt Exp $ */ /* $NetBSD: locore_subr.S,v 1.28 2006/01/23 22:52:09 uwe Exp $ */ /* @@ -497,6 +497,8 @@ NENTRY(proc_trampoline) NENTRY(sigcode) mov r15, r4 /* get pointer to sigcontext */ mov.l .L_SYS_sigreturn, r0 + .globl sigcodecall +sigcodecall: trapa #0x80 /* and call sigreturn() */ .globl sigcoderet sigcoderet: diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s index 17ec463d16e..786bb4a7ace 100644 --- a/sys/arch/sparc64/sparc64/locore.s +++ b/sys/arch/sparc64/sparc64/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.202 2023/10/24 13:20:11 claudio Exp $ */ +/* $OpenBSD: locore.s,v 1.203 2023/12/10 16:56:02 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.137 2001/08/13 06:10:10 jdolecek Exp $ */ /* @@ -5399,6 +5399,8 @@ sigcode: ! andn %o0, 0x0f, %o0 .globl sigcoderet sigcoderet: + .globl sigcodecall +sigcodecall: t ST_SYSCALL ! sigreturn(scp) ! sigreturn does not return unless it fails mov SYS_exit, %g1 ! exit(errno)