public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/vineet/arc-port-latest] aarch64: redefine RETURN_ADDRESS to strip PAC
@ 2020-07-09 16:37 Vineet Gupta
  0 siblings, 0 replies; only message in thread
From: Vineet Gupta @ 2020-07-09 16:37 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d174ec248d5b6bba3842f425f036495b682c313f

commit d174ec248d5b6bba3842f425f036495b682c313f
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Apr 15 17:40:45 2020 +0100

    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/94891: __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.
    
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Diff:
---
 sysdeps/aarch64/sysdep.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
index f442506952..ae269146e3 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/94891.  */
+# if HAVE_AARCH64_PAC_RET
+#  undef RETURN_ADDRESS
+#  define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n))
+# endif
 #endif
 
 #ifdef	__ASSEMBLER__


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-09 16:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 16:37 [glibc/vineet/arc-port-latest] aarch64: redefine RETURN_ADDRESS to strip PAC Vineet Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).