[llvm-branch-commits] [compiler-rt] 50b9db3 - [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (#100665)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 26 00:46:21 PDT 2024


Author: Alan Zhao
Date: 2024-07-26T09:46:10+02:00
New Revision: 50b9db3a2df2a69c490b50fcd2021c882ae34b85

URL: https://github.com/llvm/llvm-project/commit/50b9db3a2df2a69c490b50fcd2021c882ae34b85
DIFF: https://github.com/llvm/llvm-project/commit/50b9db3a2df2a69c490b50fcd2021c882ae34b85.diff

LOG: [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.

(cherry picked from commit 25f9415713f9f57760a5322876906dc11385ef8e)

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
index b5215c0d49c06..265a9925a15a0 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"                 \


        


More information about the llvm-branch-commits mailing list