diff options
author | mortimer <mortimer@cvs.openbsd.org> | 2018-10-01 22:49:51 +0000 |
---|---|---|
committer | mortimer <mortimer@cvs.openbsd.org> | 2018-10-01 22:49:51 +0000 |
commit | d52f9ee7f9823842409e3b386b0ab9feb0de013f (patch) | |
tree | bbcf124e2aac060ec813421de5b6cde2c480b339 /lib | |
parent | 6e7b4d0bfc36129d0c6e0ff3dd1b52d53dd97c33 (diff) |
Add retguard to arm64 libc syscalls and setjmp / longjmp.
ok kettenis@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/arch/aarch64/SYS.h | 19 | ||||
-rw-r--r-- | lib/libc/arch/aarch64/gen/_setjmp.S | 8 | ||||
-rw-r--r-- | lib/libc/arch/aarch64/gen/setjmp.S | 8 |
3 files changed, 29 insertions, 6 deletions
diff --git a/lib/libc/arch/aarch64/SYS.h b/lib/libc/arch/aarch64/SYS.h index 6b74cb7a4e1..572db2ace40 100644 --- a/lib/libc/arch/aarch64/SYS.h +++ b/lib/libc/arch/aarch64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.2 2018/05/28 19:36:43 kettenis Exp $ */ +/* $OpenBSD: SYS.h,v 1.3 2018/10/01 22:49:50 mortimer Exp $ */ /* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ /*- @@ -79,16 +79,27 @@ #define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ + SYSENTRY(x); \ + RETGUARD_SETUP(x, x15); \ + SYSTRAP(y); \ + RETGUARD_CHECK(x, x15); \ ret; \ __END(x) #define PSEUDO(x,y) \ - _SYSCALL(x,y); \ + SYSENTRY(x); \ + RETGUARD_SETUP(x, x15); \ + SYSTRAP(y); \ + bcs CERROR; \ + RETGUARD_CHECK(x, x15); \ ret; \ __END(x) #define PSEUDO_HIDDEN(x,y) \ - _SYSCALL_HIDDEN(x,y); \ + SYSENTRY_HIDDEN(x); \ + RETGUARD_SETUP(x, x15); \ + SYSTRAP(y); \ + bcs CERROR; \ + RETGUARD_CHECK(x, x15); \ ret; \ __END_HIDDEN(x) diff --git a/lib/libc/arch/aarch64/gen/_setjmp.S b/lib/libc/arch/aarch64/gen/_setjmp.S index 29f7196a716..23149acba1e 100644 --- a/lib/libc/arch/aarch64/gen/_setjmp.S +++ b/lib/libc/arch/aarch64/gen/_setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: _setjmp.S,v 1.2 2017/04/16 13:35:14 kettenis Exp $ */ +/* $OpenBSD: _setjmp.S,v 1.3 2018/10/01 22:49:50 mortimer Exp $ */ /*- * Copyright (c) 2014 Andrew Turner * Copyright (c) 2014 The FreeBSD Foundation @@ -34,6 +34,7 @@ #include <machine/setjmp.h> ENTRY(_setjmp) + RETGUARD_SETUP(_setjmp, x15) /* Store the magic value and stack pointer */ ldr x8, .Lmagic mov x9, sp @@ -57,6 +58,7 @@ ENTRY(_setjmp) /* Return value */ mov x0, #0 + RETGUARD_CHECK(_setjmp, x15) ret .align 3 .Lmagic: @@ -64,6 +66,8 @@ ENTRY(_setjmp) END_STRONG(_setjmp) ENTRY(_longjmp) + RETGUARD_SYMBOL(_longjmp) + RETGUARD_LOAD_RANDOM(_longjmp, x15) /* Check the magic value */ ldr x8, [x0], #8 ldr x9, .Lmagic @@ -81,6 +85,7 @@ ENTRY(_longjmp) ldp x25, x26, [x0], #16 ldp x27, x28, [x0], #16 ldp x29, x30, [x0], #16 + RETGUARD_CALC_COOKIE(x15) #ifndef _STANDALONE /* Restore the vfp registers */ @@ -93,6 +98,7 @@ ENTRY(_longjmp) /* Load the return value */ cmp w1, #0 csinc w0, w1, wzr, ne + RETGUARD_CHECK(_longjmp, x15) ret botch: diff --git a/lib/libc/arch/aarch64/gen/setjmp.S b/lib/libc/arch/aarch64/gen/setjmp.S index 40fba144a1b..ddbfe12039b 100644 --- a/lib/libc/arch/aarch64/gen/setjmp.S +++ b/lib/libc/arch/aarch64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.2 2017/03/08 06:28:12 drahn Exp $ */ +/* $OpenBSD: setjmp.S,v 1.3 2018/10/01 22:49:50 mortimer Exp $ */ /*- * Copyright (c) 2014 Andrew Turner * Copyright (c) 2014 The FreeBSD Foundation @@ -35,6 +35,7 @@ ENTRY(setjmp) + RETGUARD_SETUP(setjmp, x15) mov x2, x0 /* save jmpbuf in x2 */ /* Store the signal mask */ mov w1, #0 /* set */ @@ -64,6 +65,7 @@ ENTRY(setjmp) /* Return value */ mov x0, #0 + RETGUARD_CHECK(setjmp, x15) ret .align 3 @@ -72,6 +74,8 @@ ENTRY(setjmp) END_STRONG(setjmp) ENTRY(longjmp) + RETGUARD_SYMBOL(longjmp) + RETGUARD_LOAD_RANDOM(longjmp, x15) mov x2, x0 /* move jmpbuf */ mov x3, x1 /* final return value */ @@ -98,6 +102,7 @@ ENTRY(longjmp) ldp x25, x26, [x0], #16 ldp x27, x28, [x0], #16 ldp x29, x30, [x0], #16 + RETGUARD_CALC_COOKIE(x15) /* Restore the vfp registers */ ldp d8, d9, [x0], #16 @@ -108,6 +113,7 @@ ENTRY(longjmp) /* Load the return value */ cmp w3, #0 csinc w0, w3, wzr, ne + RETGUARD_CHECK(longjmp, x15) ret botch: |