[compiler-rt] [sanitizer] Fix prctl interceptor causing PAC authentication failure (PR #153081)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 10:59:55 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions inc -- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index b3053118b..a96d325d0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1286,33 +1286,33 @@ INTERCEPTOR(int, puts, char *s) {
 
 #if SANITIZER_INTERCEPT_PRCTL
 
-#if defined(__aarch64__)
+#  if defined(__aarch64__)
 // https://llvm.org/docs/PointerAuth.html
 // AArch64 is currently the only architecture with full PAC support.
 // Avoid adding PAC instructions to prevent crashes caused by
 // prctl(PR_PAC_RESET_KEYS, ...). Since PR_PAC_RESET_KEYS resets the
 // authentication key, using the old key afterward will lead to a crash.
 
-#if defined(__ARM_FEATURE_BTI_DEFAULT)
-# define BRANCH_PROTECTION_ATTRIBUTE \
-    __attribute__((target("branch-protection=bti")))
-#else
-# define BRANCH_PROTECTION_ATTRIBUTE \
-    __attribute__((target("branch-protection=none")))
-#endif
+#    if defined(__ARM_FEATURE_BTI_DEFAULT)
+#      define BRANCH_PROTECTION_ATTRIBUTE \
+        __attribute__((target("branch-protection=bti")))
+#    else
+#      define BRANCH_PROTECTION_ATTRIBUTE \
+        __attribute__((target("branch-protection=none")))
+#    endif
 
-#define PRCTL_INTERCEPTOR(ret_type, func, ...)                  \
-  DEFINE_REAL(ret_type, func, __VA_ARGS__)                      \
-  DECLARE_WRAPPER(ret_type, func, __VA_ARGS__)                  \
-  extern "C" INTERCEPTOR_ATTRIBUTE BRANCH_PROTECTION_ATTRIBUTE  \
-      ret_type WRAP(func)(__VA_ARGS__)
+#    define PRCTL_INTERCEPTOR(ret_type, func, ...)                          \
+      DEFINE_REAL(ret_type, func, __VA_ARGS__)                              \
+      DECLARE_WRAPPER(ret_type, func, __VA_ARGS__)                          \
+      extern "C" INTERCEPTOR_ATTRIBUTE BRANCH_PROTECTION_ATTRIBUTE ret_type \
+      WRAP(func)(__VA_ARGS__)
 
-#else
-#define PRCTL_INTERCEPTOR INTERCEPTOR
-#endif
+#  else
+#    define PRCTL_INTERCEPTOR INTERCEPTOR
+#  endif
 
-PRCTL_INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3,
-                  unsigned long arg4, unsigned long arg5) {
+PRCTL_INTERCEPTOR(int, prctl, int option, unsigned long arg2,
+                  unsigned long arg3, unsigned long arg4, unsigned long arg5) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, prctl, option, arg2, arg3, arg4, arg5);
   static const int PR_SET_NAME = 15;
@@ -1352,7 +1352,7 @@ PRCTL_INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3
   }
   return res;
 }
-#define INIT_PRCTL COMMON_INTERCEPT_FUNCTION(prctl)
+#  define INIT_PRCTL COMMON_INTERCEPT_FUNCTION(prctl)
 #else
 #define INIT_PRCTL
 #endif  // SANITIZER_INTERCEPT_PRCTL

``````````

</details>


https://github.com/llvm/llvm-project/pull/153081


More information about the llvm-commits mailing list