[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-07-08 Thread Kevin Athey via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1dc005aa7dc5: Add documentation for 
-fsanitize-address-use-after-return. (authored by kda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1584,7 +1584,7 @@
   : Joined<["-"], "fsanitize-address-use-after-return=">,
 MetaVarName<"">,
 Flags<[CC1Option]>,
-HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer">,
+HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer: never | runtime (default) | always">,
 Group,
 Values<"never,runtime,always">,
 NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3744,6 +3744,8 @@
   Enable linker dead stripping of globals in 
AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack 
use-after-return in AddressSanitizer: never | runtime (default) | always
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-address-use-odr-indicator
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* 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``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 
@@ -136,6 +137,26 @@
 
 Note that this option is not supported on macOS.
 
+Stack Use After Return (UAR)
+
+
+AddressSanitizer can optionally detect stack use after return problems.
+This is available by default, or explicitly
+(``-fsanitize-address-use-after-return=runtime``).
+To enable this check at runtime, set the environment variable
+``ASAN_OPTIONS=detect_stack_use_after_return=1``.
+
+Enabling this check (``-fsanitize-address-use-after-return=always``) will
+reduce code size.  The code size may be reduced further by completely
+eliminating this check (``-fsanitize-address-use-after-return=never``).
+
+To summarize: ``-fsanitize-address-use-after-return=``
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the
+runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code
+size, but not as much as ``never``).
+
 Memory leak detection
 -
 


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1584,7 +1584,7 @@
   : Joined<["-"], "fsanitize-address-use-after-return=">,
 MetaVarName<"">,
 Flags<[CC1Option]>,
-HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer">,
+HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime (default) | always">,
 Group,
 Values<"never,runtime,always">,
 NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3744,6 +3744,8 @@
   Enable linker dead stripping of globals in AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+ 

[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-07-08 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 357385.
kda marked an inline comment as done.
kda added a comment.

- removed redundant mention of the flag.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1584,7 +1584,7 @@
   : Joined<["-"], "fsanitize-address-use-after-return=">,
 MetaVarName<"">,
 Flags<[CC1Option]>,
-HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer">,
+HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer: never | runtime (default) | always">,
 Group,
 Values<"never,runtime,always">,
 NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3744,6 +3744,8 @@
   Enable linker dead stripping of globals in 
AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack 
use-after-return in AddressSanitizer: never | runtime (default) | always
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-address-use-odr-indicator
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* 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``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 
@@ -136,6 +137,26 @@
 
 Note that this option is not supported on macOS.
 
+Stack Use After Return (UAR)
+
+
+AddressSanitizer can optionally detect stack use after return problems.
+This is available by default, or explicitly
+(``-fsanitize-address-use-after-return=runtime``).
+To enable this check at runtime, set the environment variable
+``ASAN_OPTIONS=detect_stack_use_after_return=1``.
+
+Enabling this check (``-fsanitize-address-use-after-return=always``) will
+reduce code size.  The code size may be reduced further by completely
+eliminating this check (``-fsanitize-address-use-after-return=never``).
+
+To summarize: ``-fsanitize-address-use-after-return=``
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the
+runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code
+size, but not as much as ``never``).
+
 Memory leak detection
 -
 


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1584,7 +1584,7 @@
   : Joined<["-"], "fsanitize-address-use-after-return=">,
 MetaVarName<"">,
 Flags<[CC1Option]>,
-HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer">,
+HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime (default) | always">,
 Group,
 Values<"never,runtime,always">,
 NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3744,6 +3744,8 @@
   Enable linker dead stripping of globals in AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime 

[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-18 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/docs/AddressSanitizer.rst:143
+
+AddressSanitizer (``-fsanitize=address``) can optionally detect stack use after
+return problems.

Maybe -fsanitize=address is reduntant here, we are already in the 
-fsanitize=address document. Mentioning the flag in the line 11 seems more 
appropriate.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-18 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/AddressSanitizer.rst:17-19
+* 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``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)

I guess just flag name is enough here, the rest in the section below.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-17 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 352849.
kda marked an inline comment as done.
kda added a comment.
Herald added a subscriber: dang.

- Responding to comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1587,7 +1587,7 @@
   : Joined<["-"], "fsanitize-address-use-after-return=">,
 MetaVarName<"">,
 Flags<[CC1Option]>,
-HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer">,
+HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer: never | runtime (default) | always">,
 Group,
 Values<"never,runtime,always">,
 NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3724,6 +3724,8 @@
   Enable linker dead stripping of globals in 
AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack 
use-after-return in AddressSanitizer: never | runtime (default) | always
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-address-use-odr-indicator
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* 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``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 
@@ -136,6 +137,27 @@
 
 Note that this option is not supported on macOS.
 
+Stack Use After Return (UAR)
+
+
+AddressSanitizer (``-fsanitize=address``) can optionally detect stack use after
+return problems.
+This is available by default, or explicitly
+(``-fsanitize-address-use-after-return=runtime``).
+To enable this check at runtime, set the environment variable
+``ASAN_OPTIONS=detect_stack_use_after_return=1``.
+
+Enabling this check (``-fsanitize-address-use-after-return=always``) will
+reduce code size.  The code size may be reduced further by completely
+eliminating this check (``-fsanitize-address-use-after-return=never``).
+
+To summarize: ``-fsanitize-address-use-after-return=``
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the
+runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code
+size, but not as much as ``never``).
+
 Memory leak detection
 -
 


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1587,7 +1587,7 @@
   : Joined<["-"], "fsanitize-address-use-after-return=">,
 MetaVarName<"">,
 Flags<[CC1Option]>,
-HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer">,
+HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime (default) | always">,
 Group,
 Values<"never,runtime,always">,
 NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3724,6 +3724,8 @@
   Enable linker dead stripping of globals in AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack use-after-return 

[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/docs/AddressSanitizer.rst:19
+* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free

seems overloaded for the list of bug types:

Please create section, similar to 

```
Stack Use After Return
-
...
...
...
Memory leak detection
-
```

and include additional information there



Comment at: clang/docs/ClangCommandLineReference.rst:894
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers

I believe the best solution for now is just revert changes in this file and 
replace it with auto-generated version in a separate patch.



Comment at: clang/docs/UsersManual.rst:3737
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack 
use-after-return in AddressSanitizer

How about we update Options.td (in this patch) with:
HelpText<"Select the mode of detecting stack use-after-return in 
AddressSanitizer: never | runtime (default) | always">,

then we put corresponding text here and move block from UsersManual.rst:1851 
into AddressSanitizer.rst (separate section)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:3
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!

vitalybuka wrote:
> MaskRay wrote:
> > This file is generated by `clang-tblgen -gen-opt-docs`.
> > 
> > You can edit `clang/docs/UsersManual.rst` and include the information that 
> > `=never` can reduce the object file size.
> to clarify you need
> configure -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON 
> -DSPHINX_OUTPUT_MAN=ON 
> 
> and then: ninja docs-clang-html
> 
> AddressSanitizer.html  will be somewhere in output, so you can check results
> 
> @MaskRay  @rsmith However I am not sure what to do with 
> ClangCommandLineReference.rst.
> The one generated in build dir contains tens of missing flags. Still looks 
> like the public doc 
> https://clang.llvm.org/docs/ClangCommandLineReference.html is generated from 
> the one committed here.
> Should we just pick lines related to the feature and ignore the rest or don't 
> touch at all and let?
> 
The current state isn't ideal but that is what I have now 
(https://lists.llvm.org/pipermail/cfe-dev/2020-September/066900.html)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Kevin Athey via Phabricator via cfe-commits
kda added a comment.

F17415480: 
_usr_local_google_home_kda_src_uar_llvm-project_build_tools_clang_docs_html_AddressSanitizer.html.png
 




Comment at: clang/docs/AddressSanitizer.rst:18
+* Use-after-return (clang flag 
`-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable 
when compiled with `-fsanitize-address-use-after-return=runtime`)
 * Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)

vitalybuka wrote:
> Please check that this is formatted reasonable in preview.
See attached screenshot.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 352289.
kda marked 2 inline comments as done.
kda added a comment.

- more consistency.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1848,6 +1848,16 @@
   link-time optimizations like whole program inter-procedural basic block
   reordering.
 
+.. option:: -fsanitize-address-use-after-return=
+
+  When paired with ``-fsanitize=address``, this changes how detection of stack 
use-after-return (UAR) behaves.
+
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the 
runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code 
size, but not as much as ``never``).
+
+  The default is ``-fsanitize-address-use-after-return=runtime``.
+
 Profile Guided Optimization
 ---
 
@@ -3724,6 +3734,8 @@
   Enable linker dead stripping of globals in 
AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack 
use-after-return in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-address-use-odr-indicator
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific 
array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in 
AddressSanitizer.
+
+Valid options are:
+* ``never`` - Do not detect use-after-return.
+* ``runtime`` - Detect use-after-return with runtime ON/OFF switch 
(environment variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 
0)
+* ``always`` - Detect use-after-return.
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* 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``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1848,6 +1848,16 @@
   link-time optimizations like whole program inter-procedural basic block
   reordering.
 
+.. option:: -fsanitize-address-use-after-return=
+
+  When paired with ``-fsanitize=address``, this changes how detection of stack use-after-return (UAR) behaves.
+
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code size, but not as much as ``never``).
+
+  The default is ``-fsanitize-address-use-after-return=runtime``.
+
 Profile Guided Optimization
 ---
 
@@ -3724,6 +3734,8 @@
   Enable linker dead stripping of globals in AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack use-after-return in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 

[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 352287.
kda marked 2 inline comments as done.
kda added a comment.

- more beauty, added UsersManual changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1848,6 +1848,16 @@
   link-time optimizations like whole program inter-procedural basic block
   reordering.
 
+.. option:: -fsanitize-address-use-after-return=
+
+  When paired with ``-fsanitize=address``, this changes how detection of stack 
use-after-return (UAR) behaves.
+
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the 
runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code 
size, but not as much as ``never``).
+
+  The default is ``-fsanitize-address-use-after-return=runtime``.
+
 Profile Guided Optimization
 ---
 
@@ -3724,6 +3734,8 @@
   Enable linker dead stripping of globals in 
AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack 
use-after-return in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-address-use-odr-indicator
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific 
array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in 
AddressSanitizer.
+
+Valid options are:
+* ``never`` - Do not detect use-after-return.
+* ``runtime`` - Detect use-after-return with runtime ON/OFF switch 
(environment variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 
0)
+* ``always`` - Detect use-after-return.
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* Use-after-return (clang flag 
``-fsanitize-address-use-after-return=(always|runtime|never)`` default: 
``runtime``)
+* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1848,6 +1848,16 @@
   link-time optimizations like whole program inter-procedural basic block
   reordering.
 
+.. option:: -fsanitize-address-use-after-return=
+
+  When paired with ``-fsanitize=address``, this changes how detection of stack use-after-return (UAR) behaves.
+
+  * ``never``: Completely disables detection of UAR errors (reduces code size).
+  * ``runtime``: Adds the code for detection, but must be enabled via the runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
+  * ``always``: Enables detection of UAR errors in all cases. (reduces code size, but not as much as ``never``).
+
+  The default is ``-fsanitize-address-use-after-return=runtime``.
+
 Profile Guided Optimization
 ---
 
@@ -3724,6 +3734,8 @@
   Enable linker dead stripping of globals in AddressSanitizer
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
+  -fsanitize-address-use-after-return=
+  Select the mode of detecting stack use-after-return in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope 

[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a subscriber: rsmith.
vitalybuka added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:3
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!

MaskRay wrote:
> This file is generated by `clang-tblgen -gen-opt-docs`.
> 
> You can edit `clang/docs/UsersManual.rst` and include the information that 
> `=never` can reduce the object file size.
to clarify you need
configure -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON 
-DSPHINX_OUTPUT_MAN=ON 

and then: ninja docs-clang-html

AddressSanitizer.html  will be somewhere in output, so you can check results

@MaskRay  @rsmith However I am not sure what to do with 
ClangCommandLineReference.rst.
The one generated in build dir contains tens of missing flags. Still looks like 
the public doc https://clang.llvm.org/docs/ClangCommandLineReference.html is 
generated from the one committed here.
Should we just pick lines related to the feature and ignore the rest or don't 
touch at all and let?



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-15 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 352153.
kda added a comment.

- attempting to make documentation pretty.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ClangCommandLineReference.rst


Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific 
array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in 
AddressSanitizer.
+
+Valid options are:
+* ``always`` - Detect use-after-return.
+* ``runtime`` - Detect use-after-return with runtime ON/OFF switch 
(environment variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 
0)
+* ``never`` - Do not detect use-after-return.
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* Use-after-return (clang flag 
``-fsanitize-address-use-after-return=(always|runtime|never)`` default: 
``runtime``)
+* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 


Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in AddressSanitizer.
+
+Valid options are:
+* ``always`` - Detect use-after-return.
+* ``runtime`` - Detect use-after-return with runtime ON/OFF switch (environment variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 0)
+* ``never`` - Do not detect use-after-return.
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,8 +14,9 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)
-* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
+* Use-after-return (clang flag ``-fsanitize-address-use-after-return=(always|runtime|never)`` default: ``runtime``)
+* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:3
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!

This file is generated by `clang-tblgen -gen-opt-docs`.

You can edit `clang/docs/UsersManual.rst` and include the information that 
`=never` can reduce the object file size.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/AddressSanitizer.rst:17
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* Use-after-return (clang flag 
`-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable 
when compiled with `-fsanitize-address-use-after-return=runtime`)

rst uses two backsticks instead of one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-11 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 351571.
kda marked an inline comment as done.
kda added a comment.

- Revised according to feedback.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ClangCommandLineReference.rst


Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific 
array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in 
AddressSanitizer.
+
+Valid options are:
+* ``always`` - Detect use-after-return.
+* ``runtime`` - Detect use-after-return with runtime ON/OFF switch 
(environment variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 
0)
+* ``never`` - Do not detect use-after-return.
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,7 +14,8 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* Use-after-return (clang flag 
`-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable 
when compiled with `-fsanitize-address-use-after-return=runtime`)
 * Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
 * Double-free, invalid free
 * Memory leaks (experimental)


Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in AddressSanitizer.
+
+Valid options are:
+* ``always`` - Detect use-after-return.
+* ``runtime`` - Detect use-after-return with runtime ON/OFF switch (environment variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 0)
+* ``never`` - Do not detect use-after-return.
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,7 +14,8 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* Use-after-return (clang flag `-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable when compiled with `-fsanitize-address-use-after-return=runtime`)
 * Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
 * Double-free, invalid free
 * Memory leaks (experimental)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/docs/AddressSanitizer.rst:18
+* Use-after-return (clang flag 
`-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable 
when compiled with `-fsanitize-address-use-after-return=runtime`)
 * Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)

Please check that this is formatted reasonable in preview.



Comment at: clang/docs/ClangCommandLineReference.rst:889
+Valid options are:
+* ``always`` - Always detect use-after-return.  (Code generated and always 
enabled.)
+* ``runtime`` - Detect use-after-return at runtime if enabled by runtime 
command line (flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)

"Code generated and always enabled." is implementation details.
Something like this? 

```
Valid options are:
* ``always`` - Detect use-after-return.
* ``runtime`` - Detect use-after-return with runtime ON/OFF switch (environment 
variable `ASAN_OPTIONS=detect_stack_use_after_return=1`, default: 0)
* ``never`` - Do not detect use-after-return.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104155/new/

https://reviews.llvm.org/D104155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104155: Add documentation for -fsanitize-address-use-after-return.

2021-06-11 Thread Kevin Athey via Phabricator via cfe-commits
kda created this revision.
kda added a reviewer: vitalybuka.
kda requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

for issue: https://github.com/google/sanitizers/issues/1394


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104155

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ClangCommandLineReference.rst


Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific 
array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in 
AddressSanitizer.
+
+Valid options are:
+* ``always`` - Always detect use-after-return.  (Code generated and always 
enabled.)
+* ``runtime`` - Detect use-after-return at runtime if enabled by runtime 
command line (flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* ``never`` - Never detect use-after-return.  (Code not generated for 
detection.)
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,7 +14,8 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag 
`ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* Use-after-return (clang flag 
`-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable 
when compiled with `-fsanitize-address-use-after-return=runtime`)
 * Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
 * Double-free, invalid free
 * Memory leaks (experimental)


Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -881,6 +881,15 @@
 * ``global`` - Emit module destructors that are called via a platform specific array (see `llvm.global_dtors`).
 * ``none`` - Do not emit module destructors.
 
+.. option:: -fsanitize-address-use-after-return=
+
+Select the enabling method of detecting stack use-after-return in AddressSanitizer.
+
+Valid options are:
+* ``always`` - Always detect use-after-return.  (Code generated and always enabled.)
+* ``runtime`` - Detect use-after-return at runtime if enabled by runtime command line (flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* ``never`` - Never detect use-after-return.  (Code not generated for detection.)
+
 .. option:: -fsanitize-ignorelist=
 
 Path to ignorelist file for sanitizers
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -14,7 +14,8 @@
 
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
-* Use-after-return (runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)
+* Use-after-return (clang flag `-fsanitize-address-use-after-return=(always|runtime|never)` default: runtime)
+  * Add runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1` to enable when compiled with `-fsanitize-address-use-after-return=runtime`)
 * Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
 * Double-free, invalid free
 * Memory leaks (experimental)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits