[compiler-rt] [tsan] Lazily call 'personality' to minimize sandbox violations (PR #79334)

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 10:17:03 PST 2024


================
@@ -267,6 +267,14 @@ static void ReExecIfNeeded() {
   if (reexec) {
     // Don't check the address space since we're going to re-exec anyway.
   } else if (!CheckAndProtect(false, false, false)) {
+    // ASLR personality check.
+    // N.B. 'personality' is sometimes forbidden by sandboxes, so we only call
+    // this as a last resort (when the memory mapping is incompatible and TSan
+    // would fail anyway).
+    int old_personality = personality(0xffffffff);
----------------
dvyukov wrote:

I meant adding this to a test:
```
extern "C" int personality(unsigned long) { abort(); }
```

Such test should abort w/o this fix.
Probably better to add to sanitizer_common tests so that all sanitizers are tested.

Of course, there can be sandboxes that prohibit too much and sanitizers won't work under these sandboxes. We can't fix that. But we do want to avoid personality and we want it to not regress tomorrow.

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


More information about the llvm-commits mailing list