aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2020-04-15 17:40:45 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-06-12 14:34:39 +0100
commita8aad403a6d9e4904a5699ebd4c26424ab105076 (patch)
tree173554f292f353dd3c6e221582edb9abedbff48f
parentf70dbaf7a1d2664fbed2cdcf6a3da40c37a442c0 (diff)
downloadglibc-a8aad403a6d9e4904a5699ebd4c26424ab105076.tar
glibc-a8aad403a6d9e4904a5699ebd4c26424ab105076.tar.gz
glibc-a8aad403a6d9e4904a5699ebd4c26424ab105076.tar.bz2
glibc-a8aad403a6d9e4904a5699ebd4c26424ab105076.zip
aarch64: redefine RETURN_ADDRESS to strip PAC
RETURN_ADDRESS is used at several places in glibc to mean a valid code address of the call site, but with pac-ret it may contain a pointer authentication code (PAC), so its definition is adjusted. This is gcc PR target/95891: __builtin_return_address should not expose signed pointers to user code where it can cause ABI issues. In glibc RETURN_ADDRESS is only changed if it is built with pac-ret. There is no detection for the specific gcc issue because it is hard to test and the additional xpac does not cause problems.
-rw-r--r--sysdeps/aarch64/sysdep.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
index 2879aeaa5c..593bdd35a2 100644
--- a/sysdeps/aarch64/sysdep.h
+++ b/sysdeps/aarch64/sysdep.h
@@ -44,6 +44,13 @@ strip_pac (void *p)
asm ("hint 7 // xpaclri" : "+r"(ra));
return ra;
}
+
+/* This is needed when glibc is built with -mbranch-protection=pac-ret
+ with a gcc that is affected by PR target/95891. */
+# if HAVE_AARCH64_PAC_RET
+# undef RETURN_ADDRESS
+# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n))
+# endif
#endif
#ifdef __ASSEMBLER__