Since we got rid of padded syscalls we have enough registers to do this.
ok deraadt@ ok kettenis@
-/* $OpenBSD: SYS.h,v 1.20 2016/09/06 18:33:35 kettenis Exp $ */
+/* $OpenBSD: SYS.h,v 1.21 2023/01/11 01:55:17 mortimer Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
HANDLE_ERRNO
-/* return, handling errno for failed calls */
-#define _RSYSCALL_RET \
- jc 99f; \
- ret; \
- 99: SET_ERRNO; \
- ret
-
#define PSEUDO_NOERROR(x,y) \
- _SYSCALL_NOERROR(x,y); \
+ SYSENTRY(x); \
+ RETGUARD_SETUP(_thread_sys_##x, r11); \
+ RETGUARD_PUSH(r11); \
+ SYSTRAP(y); \
+ RETGUARD_POP(r11); \
+ RETGUARD_CHECK(_thread_sys_##x, r11); \
ret; \
SYSCALL_END(x)
#define PSEUDO(x,y) \
- _SYSCALL_NOERROR(x,y); \
- _RSYSCALL_RET; \
+ SYSENTRY(x); \
+ RETGUARD_SETUP(_thread_sys_##x, r11); \
+ RETGUARD_PUSH(r11); \
+ SYSTRAP(y); \
+ HANDLE_ERRNO; \
+ RETGUARD_POP(r11); \
+ RETGUARD_CHECK(_thread_sys_##x, r11); \
+ ret; \
SYSCALL_END(x)
+
#define PSEUDO_HIDDEN(x,y) \
- _SYSCALL_HIDDEN_NOERROR(x,y); \
- _RSYSCALL_RET; \
+ SYSENTRY_HIDDEN(x); \
+ RETGUARD_SETUP(_thread_sys_##x, r11); \
+ RETGUARD_PUSH(r11); \
+ SYSTRAP(y); \
+ HANDLE_ERRNO; \
+ RETGUARD_POP(r11); \
+ RETGUARD_CHECK(_thread_sys_##x , r11); \
+ ret; \
SYSCALL_END_HIDDEN(x)
#define RSYSCALL_NOERROR(x) \
-/* $OpenBSD: Ovfork.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.9 2023/01/11 01:55:17 mortimer Exp $ */
/* $NetBSD: Ovfork.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
SYSENTRY_HIDDEN(vfork)
popq %r9 /* my rta into r9 */
+ RETGUARD_SETUP(_thread_sys_vfork, r11);
+ RETGUARD_PUSH(r11);
SYSTRAP(vfork)
+ RETGUARD_POP(r11)
jc 1f
jmp *%r9
1:
pushq %r9
SET_ERRNO
+ RETGUARD_CHECK(_thread_sys_vfork, r11);
ret
SYSCALL_END_HIDDEN(vfork)
-/* $OpenBSD: brk.S,v 1.12 2022/01/01 23:47:14 guenther Exp $ */
+/* $OpenBSD: brk.S,v 1.13 2023/01/11 01:55:17 mortimer Exp $ */
/* $NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
.type __minbrk,@object
ENTRY_NB(brk)
+ RETGUARD_SETUP(brk, r11);
+ RETGUARD_PUSH(r11);
cmpq %rdi,__minbrk(%rip)
jb 1f
movq __minbrk(%rip),%rdi
jc 1f
movq %rdi,__curbrk(%rip)
xorl %eax,%eax
- ret
+ jmp 2f
1:
SET_ERRNO
+2:
+ RETGUARD_POP(r11);
+ RETGUARD_CHECK(brk, r11);
ret
END(brk)
.weak brk
-/* $OpenBSD: sbrk.S,v 1.12 2022/01/01 23:47:14 guenther Exp $ */
+/* $OpenBSD: sbrk.S,v 1.13 2023/01/11 01:55:17 mortimer Exp $ */
/* $NetBSD: sbrk.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
.type __curbrk,@object
ENTRY_NB(sbrk)
+ RETGUARD_SETUP(sbrk, r11);
+ RETGUARD_PUSH(r11);
movq __curbrk(%rip),%rax
movslq %edi,%rsi
movq %rsi,%rdi
jc 1f
movq __curbrk(%rip),%rax
addq %rsi,__curbrk(%rip)
- ret
+ jmp 2f
1:
SET_ERRNO
+2:
+ RETGUARD_POP(r11);
+ RETGUARD_CHECK(sbrk, r11);
ret
END(sbrk)
.weak sbrk
-/* $OpenBSD: sigpending.S,v 1.3 2015/06/17 03:04:50 uebayasi Exp $ */
+/* $OpenBSD: sigpending.S,v 1.4 2023/01/11 01:55:17 mortimer Exp $ */
/* $NetBSD: sigpending.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
#include "SYS.h"
SYSCALL(sigpending)
+ RETGUARD_SETUP(_thread_sys_sigpending, r11);
+ RETGUARD_PUSH(r11);
movl %eax,(%rdi) # store old mask
xorl %eax,%eax
+ RETGUARD_POP(r11)
+ RETGUARD_CHECK(_thread_sys_sigpending, r11);
ret
SYSCALL_END(sigpending)
-/* $OpenBSD: sigprocmask.S,v 1.9 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.10 2023/01/11 01:55:17 mortimer Exp $ */
/* $NetBSD: sigprocmask.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
#include "SYS.h"
SYSENTRY_HIDDEN(sigprocmask)
+ RETGUARD_SETUP(_thread_sys_sigprocmask, r11);
+ RETGUARD_PUSH(r11);
testq %rsi,%rsi # check new sigset pointer
jnz 1f # if not null, indirect
movl $1,%edi # SIG_BLOCK
movl %eax,(%rdx) # store old mask
3:
xorl %eax,%eax
- ret
+ jmp 2f
1:
SET_ERRNO
+2:
+ RETGUARD_POP(r11);
+ RETGUARD_CHECK(_thread_sys_sigprocmask, r11);
ret
SYSCALL_END_HIDDEN(sigprocmask)
-/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.8 2023/01/11 01:55:17 mortimer Exp $ */
/* $NetBSD: sigsuspend.S,v 1.1 2001/06/19 00:25:07 fvdl Exp $ */
/*-
#include "SYS.h"
SYSENTRY_HIDDEN(sigsuspend)
+ RETGUARD_SETUP(_thread_sys_sigsuspend, r11);
+ RETGUARD_PUSH(r11);
movl (%rdi),%edi # indirect to mask arg
SYSTRAP(sigsuspend)
SET_ERRNO
+ RETGUARD_POP(r11);
+ RETGUARD_CHECK(_thread_sys_sigsuspend, r11);
ret
SYSCALL_END_HIDDEN(sigsuspend)
-/* $OpenBSD: tfork_thread.S,v 1.10 2020/10/18 14:28:17 deraadt Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.11 2023/01/11 01:55:17 mortimer Exp $ */
/*-
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
* Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>
ENTRY(__tfork_thread)
.cfi_startproc
+ RETGUARD_SETUP(__tfork_thread, r11);
+ RETGUARD_PUSH(r11);
movq %rdx, %r8
movq %rcx, %r9
*/
cmpl $0, %eax
jz 1f
- ret
+ jmp 3f
/* the retpoline we'll use to call the child's main */
_ALIGN_TRAPS
*/
2:
SET_ERRNO
+3:
+ RETGUARD_POP(r11);
+ RETGUARD_CHECK(__tfork_thread, r11);
ret
.cfi_endproc
END(__tfork_thread)
-/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */
+/* $OpenBSD: SYS.h,v 1.2 2023/01/11 01:55:17 mortimer Exp $ */
/*
* Copyright (c) 2002,2004 Dale Rahn
.type __CONCAT(_dl_,n), @function ;\
.align 16,0xcc ;\
__CONCAT(_dl_,n): ;\
+ RETGUARD_SETUP(_dl_##n, r11) ;\
+ RETGUARD_PUSH(r11) ;\
movl $(__CONCAT(SYS_,n)), %eax ;\
movq %rcx, %r10 ;\
syscall ;\
- jb 1f ;\
- ret ;\
-1: neg %rax ;\
+ jnc 1f ;\
+ neg %rax ;\
+1: RETGUARD_POP(r11) ;\
+ RETGUARD_CHECK(_dl_##n, r11) ;\
ret