diff mbox

Enable -fsanitize-address-use-after-scope only if -fsanitize=address is enabled

Message ID CACT4Y+YhQxVg2HcEizrwnXiwFMV2=72qDaA9nyZVsWVMwCyt=Q@mail.gmail.com
State New
Headers show

Commit Message

Dmitry Vyukov Dec. 7, 2016, 7:30 p.m. UTC
On Wed, Dec 7, 2016 at 8:23 PM, Sandra Loosemore
<sandra@codesourcery.com> wrote:
> On 12/07/2016 11:44 AM, Dmitry Vyukov wrote:
>>
>> Hello,
>>
>> Revision 241896 added -fsanitize-address-use-after-scope and enabled
>> it whenever any sanitizer is enabled. This caused problems for kernel
>> which does not have necessary callbacks for
>> -fsanitize-address-use-after-scope. I've added the callbacks to kernel
>> tip, but older kernel branches still don't have them.
>>
>> So enable -fsanitize-address-use-after-scope iff -fsanitize=address is
>> enabled. In the kernel we will check if
>> -fsanitize-address-use-after-scope is present and enable it only on
>> versions that have the callbacks.
>> As a side effect this also doesn't enable
>> -fsanitize-address-use-after-scope for e.g. -fsanitize=thread, which
>> is I believe unnecessary.
>>
>> OK for trunk?
>>
>> Index: gcc/ChangeLog
>> ===================================================================
>> --- gcc/ChangeLog       (revision 243344)
>> +++ gcc/ChangeLog       (working copy)
>> @@ -1,3 +1,10 @@
>> +2016-12-07  Dmitry Vyukov  <dvyukov@google.com>
>> +
>> +       * opts.c (finish_options): Enable
>> +       -fsanitize-address-use-after-scope only if
>> +       -fsanitize=address is enabled (not
>> +       -fsanitize=kernel-address).
>> +
>>  2016-12-07  Bin Cheng  <bin.cheng@arm.com>
>>
>>         PR tree-optimization/78691
>
>
> You need to fix doc/invoke.texi as well to reflect this change.

Done.

Attached updated patch.

Comments

Sandra Loosemore Dec. 7, 2016, 9:57 p.m. UTC | #1
On 12/07/2016 12:30 PM, Dmitry Vyukov wrote:
> On Wed, Dec 7, 2016 at 8:23 PM, Sandra Loosemore
> <sandra@codesourcery.com> wrote:
>>
>> You need to fix doc/invoke.texi as well to reflect this change.
>
> Done.
>
> Attached updated patch.

The documentation change is OK.

-Sandra
Dmitry Vyukov Dec. 8, 2016, 2:32 p.m. UTC | #2
On Wed, Dec 7, 2016 at 10:57 PM, Sandra Loosemore
<sandra@codesourcery.com> wrote:
> On 12/07/2016 12:30 PM, Dmitry Vyukov wrote:
>>
>> On Wed, Dec 7, 2016 at 8:23 PM, Sandra Loosemore
>> <sandra@codesourcery.com> wrote:
>>>
>>>
>>> You need to fix doc/invoke.texi as well to reflect this change.
>>
>>
>> Done.
>>
>> Attached updated patch.
>
>
> The documentation change is OK.


Submitted in 243441
diff mbox

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 243344)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,11 @@ 
+2016-12-07  Dmitry Vyukov  <dvyukov@google.com>
+
+	* opts.c (finish_options): Enable
+	-fsanitize-address-use-after-scope only if -fsanitize=address is enabled
+	(not -fsanitize=kernel-address).
+	* doc/invoke.texi (-fsanitize=kernel-address):
+	Don't say that it enables -fsanitize-address-use-after-scope.
+
 2016-12-07  Bin Cheng  <bin.cheng@arm.com>
 
 	PR tree-optimization/78691
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 243344)
+++ gcc/doc/invoke.texi	(working copy)
@@ -10559,7 +10559,6 @@ 
 @item -fsanitize=kernel-address
 @opindex fsanitize=kernel-address
 Enable AddressSanitizer for Linux kernel.
-The option enables @option{-fsanitize-address-use-after-scope}.
 See @uref{https://github.com/google/kasan/wiki} for more details.
 
 @item -fsanitize=thread
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 243344)
+++ gcc/opts.c	(working copy)
@@ -990,7 +990,7 @@ 
 
   /* Enable -fsanitize-address-use-after-scope if address sanitizer is
      enabled.  */
-  if (opts->x_flag_sanitize
+  if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
       && !opts_set->x_flag_sanitize_address_use_after_scope)
     opts->x_flag_sanitize_address_use_after_scope = true;