about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/aarch64/setcontext.S
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2023-04-04 10:42:21 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2024-02-02 15:58:11 +0000
commit54e90582aabdb44f010ad5dfd64ce9c3e6d33914 (patch)
treed9fb977650c38e5ff7395ccfd977acd3b117f53e /sysdeps/unix/sysv/linux/aarch64/setcontext.S
parent99f884d57f17afea877006284f469747711e1d51 (diff)
downloadglibc-54e90582aabdb44f010ad5dfd64ce9c3e6d33914.tar.gz
glibc-54e90582aabdb44f010ad5dfd64ce9c3e6d33914.tar.xz
glibc-54e90582aabdb44f010ad5dfd64ce9c3e6d33914.zip
aarch64: Add GCS support for makecontext
Changed the makecontext logic: previously the first setcontext jumped
straight to the user callback function and the return address is set
to __startcontext. This does not work when GCS is enabled as the
integrity of the return address is protected, so instead the context
is setup such that setcontext jumps to __startcontext which calls the
user callback (passed in x20).

The map_shadow_stack syscall is used to allocate a suitably sized GCS
(which includes some reserved area to account for altstack signal
handlers and otherwise supports maximum number of 16 byte aligned
stack frames on the given stack) however the GCS is never freed as
the lifetime of ucontext and related stack is user managed.
Diffstat (limited to 'sysdeps/unix/sysv/linux/aarch64/setcontext.S')
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/setcontext.S4
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/aarch64/setcontext.S b/sysdeps/unix/sysv/linux/aarch64/setcontext.S
index c08e83ee60..6aa7236693 100644
--- a/sysdeps/unix/sysv/linux/aarch64/setcontext.S
+++ b/sysdeps/unix/sysv/linux/aarch64/setcontext.S
@@ -181,7 +181,11 @@ L(gcs_done):
 PSEUDO_END (__setcontext)
 weak_alias (__setcontext, setcontext)
 
+/* makecontext start function: receives uc_link in x19 and func in x20.
+   Arguments of func, x29, x30 and sp are set up by the caller.  */
 ENTRY (__startcontext)
+	cfi_undefined (x30)
+	blr	x20
 	mov	x0, x19
 	cbnz	x0, __setcontext
 1:	b       HIDDEN_JUMPTARGET (exit)