[compiler-rt] [sanitizer] Disallow external_symbolizer_path with AT_SECURE (PR #92611)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 15:14:50 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Florian Mayer (fmayer)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/92611.diff


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp (+8-1) 


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index 0ddc24802d216..68d51dd1cb9b7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -25,6 +25,7 @@
 #  include "sanitizer_common.h"
 #  include "sanitizer_file.h"
 #  include "sanitizer_flags.h"
+#  include "sanitizer_getauxval.h"
 #  include "sanitizer_internal_defs.h"
 #  include "sanitizer_linux.h"
 #  include "sanitizer_placement_new.h"
@@ -408,7 +409,13 @@ const char *Symbolizer::PlatformDemangle(const char *name) {
 
 static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
   const char *path = common_flags()->external_symbolizer_path;
-
+  // This is so we can use the weak definition from sanitizer_getauxval.h
+  if (&getauxval && getauxval(/* AT_SECURE */ 23) != 0) {
+    Report(
+        "ERROR: external_symbolizer_path cannot be used for AT_SECURE "
+        "(e.g. setuid binaries).\n");
+    Die();
+  }
   if (path && internal_strchr(path, '%')) {
     char *new_path = (char *)InternalAlloc(kMaxPathLength);
     SubstituteForFlagValue(path, new_path, kMaxPathLength);

``````````

</details>


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


More information about the llvm-commits mailing list