Skip to content

Commit 7858219

Browse files
committed
[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
1 parent a70cf56 commit 7858219

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

clang/docs/AddressSanitizer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ following types of bugs:
1515
* Out-of-bounds accesses to heap, stack and globals
1616
* Use-after-free
1717
* Use-after-return (clang flag ``-fsanitize-address-use-after-return=(never|runtime|always)`` default: ``runtime``)
18-
* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
18+
* Enable with: ``ASAN_OPTIONS=detect_stack_use_after_return=1`` (already enabled on Linux).
19+
* Disable with: ``ASAN_OPTIONS=detect_stack_use_after_return=0``.
1920
* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
2021
* Double-free, invalid free
2122
* Memory leaks (experimental)

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ Non-comprehensive list of changes in this release
178178
- Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
179179
- Remove anonymous tag locations.
180180
- Beautify dump format, add indent for nested struct and struct members.
181-
- Enable MSAN_OPTIONS=poison_in_dtor=1 by default.
181+
- Previously disabled sanitizer options now enabled by default:
182+
- ASAN_OPTIONS=detect_stack_use_after_return=1 (only on Linux).
183+
- MSAN_OPTIONS=poison_in_dtor=1.
182184

183185
New Compiler Flags
184186
------------------

compiler-rt/lib/asan/asan_flags.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ ASAN_FLAG(
4949
"to find more errors.")
5050
ASAN_FLAG(bool, replace_intrin, true,
5151
"If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
52-
ASAN_FLAG(bool, detect_stack_use_after_return, false,
52+
ASAN_FLAG(bool, detect_stack_use_after_return,
53+
SANITIZER_LINUX && !SANITIZER_ANDROID,
5354
"Enables stack-use-after-return checking at run-time.")
54-
ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
55+
ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
5556
"Minimum fake stack size log.")
5657
ASAN_FLAG(int, max_uar_stack_size_log,
5758
20, // 1Mb per size class, i.e. ~11Mb per thread

0 commit comments

Comments
 (0)