[compiler-rt] 7858219 - [asan] Enable detect_stack_use_after_return=1 by default on Linux

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 21:08:26 PDT 2022


Author: Vitaly Buka
Date: 2022-04-28T21:08:16-07:00
New Revision: 78582194361e4454e95d3af23367b81dd63b7943

URL: https://github.com/llvm/llvm-project/commit/78582194361e4454e95d3af23367b81dd63b7943
DIFF: https://github.com/llvm/llvm-project/commit/78582194361e4454e95d3af23367b81dd63b7943.diff

LOG: [asan] Enable detect_stack_use_after_return=1 by default on Linux

By default -fsanitize=address already compiles with this check, why not use it.
For compatibly it can be disabled with env ASAN_OPTIONS=detect_stack_use_after_return=0.

Reviewed By: eugenis, kda, #sanitizers, hans

Differential Revision: https://reviews.llvm.org/D124057

Added: 
    

Modified: 
    clang/docs/AddressSanitizer.rst
    clang/docs/ReleaseNotes.rst
    compiler-rt/lib/asan/asan_flags.inc

Removed: 
    


################################################################################
diff  --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index cc51a8d8a34fd..37f34cb0cc993 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -15,7 +15,8 @@ following types of bugs:
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
 * Use-after-return (clang flag ``-fsanitize-address-use-after-return=(never|runtime|always)`` default: ``runtime``)
-    * Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+    * Enable with: ``ASAN_OPTIONS=detect_stack_use_after_return=1`` (already enabled on Linux).
+    * Disable with: ``ASAN_OPTIONS=detect_stack_use_after_return=0``.
 * Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2dacf3a94cdff..652ef45b24df6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -178,7 +178,9 @@ Non-comprehensive list of changes in this release
   - Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
   - Remove anonymous tag locations.
   - Beautify dump format, add indent for nested struct and struct members.
-- Enable MSAN_OPTIONS=poison_in_dtor=1 by default.
+- Previously disabled sanitizer options now enabled by default:
+  - ASAN_OPTIONS=detect_stack_use_after_return=1 (only on Linux).
+  - MSAN_OPTIONS=poison_in_dtor=1.
 
 New Compiler Flags
 ------------------

diff  --git a/compiler-rt/lib/asan/asan_flags.inc b/compiler-rt/lib/asan/asan_flags.inc
index 514b225c40731..314ed19353586 100644
--- a/compiler-rt/lib/asan/asan_flags.inc
+++ b/compiler-rt/lib/asan/asan_flags.inc
@@ -49,9 +49,10 @@ ASAN_FLAG(
     "to find more errors.")
 ASAN_FLAG(bool, replace_intrin, true,
           "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
-ASAN_FLAG(bool, detect_stack_use_after_return, false,
+ASAN_FLAG(bool, detect_stack_use_after_return,
+          SANITIZER_LINUX && !SANITIZER_ANDROID,
           "Enables stack-use-after-return checking at run-time.")
-ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
+ASAN_FLAG(int, min_uar_stack_size_log, 16,  // We can't do smaller anyway.
           "Minimum fake stack size log.")
 ASAN_FLAG(int, max_uar_stack_size_log,
           20, // 1Mb per size class, i.e. ~11Mb per thread


        


More information about the llvm-commits mailing list