]> git.ipfire.org Git - thirdparty/glibc.git/commit
aarch64: Add GCS support for makecontext
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 4 Apr 2023 09:42:21 +0000 (10:42 +0100)
committerYury Khrustalev <yury.khrustalev@arm.com>
Mon, 20 Jan 2025 09:22:41 +0000 (09:22 +0000)
commit3ac237fb716b86ba7967edb84eb85d15364aaebc
tree51dcd944ebd206276009c759168e869eb0ffd971
parent7d22054db7df3b0b84f1a2142195e27c5d34285b
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.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/unix/sysv/linux/aarch64/makecontext.c
sysdeps/unix/sysv/linux/aarch64/setcontext.S