From 25f9415713f9f57760a5322876906dc11385ef8e Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Thu, 25 Jul 2024 17:38:44 -0700 Subject: [PATCH] [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (#100665) If the inline asm version of `ptrauth_strip` is used instead of the builtin, the inline asm implementation currently returns an unsigned long, causing an incompatible pointer conversion issue. The spec for `ptrauth_sign` is that the result has the same type as the original value, so we add a cast to the result of the inline asm. --- compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h index b5215c0d49c06b..265a9925a15a03 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h @@ -18,7 +18,7 @@ // the NOP space so will do nothing when it is not enabled or not available. # define ptrauth_strip(__value, __key) \ ({ \ - unsigned long ret; \ + __typeof(__value) ret; \ asm volatile( \ "mov x30, %1\n\t" \ "hint #7\n\t" \