| 
10 | 10 | #define SANITIZER_PTRAUTH_H  | 
11 | 11 | 
 
  | 
12 | 12 | #if __has_feature(ptrauth_intrinsics)  | 
13 |  | -#include <ptrauth.h>  | 
 | 13 | +#  include <ptrauth.h>  | 
14 | 14 | #elif defined(__ARM_FEATURE_PAC_DEFAULT) && !defined(__APPLE__)  | 
15 | 15 | // On the stack the link register is protected with Pointer  | 
16 | 16 | // Authentication Code when compiled with -mbranch-protection.  | 
17 | 17 | // Let's stripping the PAC unconditionally because xpaclri is in  | 
18 | 18 | // the NOP space so will do nothing when it is not enabled or not available.  | 
19 |  | -#define ptrauth_strip(__value, __key)     \  | 
20 |  | -  ({                                      \  | 
21 |  | -      unsigned long ret;                  \  | 
22 |  | -      asm volatile(                       \  | 
23 |  | -        "mov x30, %1\n\t"                 \  | 
24 |  | -        "hint #7\n\t"                     \  | 
25 |  | -        "mov %0, x30\n\t"                 \  | 
26 |  | -        "mov x30, xzr\n\t"                \  | 
27 |  | -        : "=r"(ret)                       \  | 
28 |  | -        : "r"(__value)                    \  | 
29 |  | -        : "x30");                         \  | 
30 |  | -      ret;                                \  | 
31 |  | -  })  | 
32 |  | -#define ptrauth_auth_data(__value, __old_key, __old_data) __value  | 
33 |  | -#define ptrauth_string_discriminator(__string) ((int)0)  | 
 | 19 | +#  define ptrauth_strip(__value, __key) \  | 
 | 20 | +    ({                                  \  | 
 | 21 | +      unsigned long ret;                \  | 
 | 22 | +      asm volatile(                     \  | 
 | 23 | +          "mov x30, %1\n\t"             \  | 
 | 24 | +          "hint #7\n\t"                 \  | 
 | 25 | +          "mov %0, x30\n\t"             \  | 
 | 26 | +          "mov x30, xzr\n\t"            \  | 
 | 27 | +          : "=r"(ret)                   \  | 
 | 28 | +          : "r"(__value)                \  | 
 | 29 | +          : "x30");                     \  | 
 | 30 | +      ret;                              \  | 
 | 31 | +    })  | 
 | 32 | +#  define ptrauth_auth_data(__value, __old_key, __old_data) __value  | 
 | 33 | +#  define ptrauth_string_discriminator(__string) ((int)0)  | 
34 | 34 | #else  | 
35 | 35 | // Copied from <ptrauth.h>  | 
36 |  | -#define ptrauth_strip(__value, __key) __value  | 
37 |  | -#define ptrauth_auth_data(__value, __old_key, __old_data) __value  | 
38 |  | -#define ptrauth_string_discriminator(__string) ((int)0)  | 
 | 36 | +#  define ptrauth_strip(__value, __key) __value  | 
 | 37 | +#  define ptrauth_auth_data(__value, __old_key, __old_data) __value  | 
 | 38 | +#  define ptrauth_string_discriminator(__string) ((int)0)  | 
39 | 39 | #endif  | 
40 | 40 | 
 
  | 
41 | 41 | #define STRIP_PAC_PC(pc) ((uptr)ptrauth_strip(pc, 0))  | 
 | 
0 commit comments