[compiler-rt] [sanitizer-common] [Darwin] Provide warning if task_set_exc_guard_behavior errors (PR #165907)
Andrew Haberlandt via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 31 12:11:47 PDT 2025
https://github.com/ndrewh updated https://github.com/llvm/llvm-project/pull/165907
>From d41ba6149ddff40e4e05d7510b9c57fc2ffa383e Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Fri, 31 Oct 2025 11:40:22 -0700
Subject: [PATCH] [sanitizer-common] [Darwin] Provide warning if
task_set_exc_guard_behavior errors
---
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index b0a29db908639..b3c2ede4f6fb4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -960,7 +960,18 @@ static void DisableMmapExcGuardExceptions() {
RTLD_DEFAULT, "task_set_exc_guard_behavior");
if (set_behavior == nullptr) return;
const task_exc_guard_behavior_t task_exc_guard_none = 0;
- set_behavior(mach_task_self(), task_exc_guard_none);
+ kern_return_t res = set_behavior(mach_task_self(), task_exc_guard_none);
+ if (res != KERN_SUCCESS) {
+ Report(
+ "WARN: task_set_exc_guard_behavior returned %d (%s), "
+ "mmap may fail unexpectedly.\n",
+ res, mach_error_string(res));
+ if (res == KERN_DENIED) {
+ Report(
+ "HINT: Check that task_set_exc_guard_behavior is allowed by "
+ "sandbox.\n");
+ }
+ }
}
static void VerifyInterceptorsWorking();
More information about the llvm-commits
mailing list