From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id C6E33386184A; Wed, 8 Jul 2020 14:04:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6E33386184A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc] aarch64: redefine RETURN_ADDRESS to strip PAC X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/master X-Git-Oldrev: c94767712b06fd37e82d23f86d4d6e1c93948d8a X-Git-Newrev: d174ec248d5b6bba3842f425f036495b682c313f Message-Id: <20200708140420.C6E33386184A@sourceware.org> Date: Wed, 8 Jul 2020 14:04:20 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jul 2020 14:04:20 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d174ec248d5b6bba3842f425f036495b682c313f commit d174ec248d5b6bba3842f425f036495b682c313f Author: Szabolcs Nagy 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 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__