public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Yury Gribov <y.gribov@samsung.com>,
	       "Joseph S. Myers" <joseph@codesourcery.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	       Konstantin Serebryany <konstantin.s.serebryany@gmail.com>,
	       Dmitry Vyukov <dvyukov@google.com>,
	       Andrey Ryabinin <a.ryabinin@samsung.com>,
	       Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Subject: Re: [PATCH][PING] Enable -fsanitize-recover for KASan
Date: Thu, 18 Sep 2014 10:53:00 -0000	[thread overview]
Message-ID: <20140918105251.GD17454@tucnak.redhat.com> (raw)
In-Reply-To: <5416B3A2.4050200@samsung.com>

On Mon, Sep 15, 2014 at 01:38:42PM +0400, Yury Gribov wrote:
> --- a/gcc/builtins.def
> +++ b/gcc/builtins.def
> @@ -176,7 +176,7 @@ along with GCC; see the file COPYING3.  If not see
>    DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,    \
>  	       true, true, true, ATTRS, true, \
>  	      (flag_sanitize & (SANITIZE_ADDRESS | SANITIZE_THREAD \
> -				| SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT)))
> +				| SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT)))

This is too long line after the change.

> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -8236,7 +8236,7 @@ sanitize_spec_function (int argc, const char **argv)
>    if (strcmp (argv[0], "thread") == 0)
>      return (flag_sanitize & SANITIZE_THREAD) ? "" : NULL;
>    if (strcmp (argv[0], "undefined") == 0)
> -    return ((flag_sanitize & (SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT))
> +    return ((flag_sanitize & (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT))

Likewise.

> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -1551,6 +1551,12 @@ common_handle_option (struct gcc_options *opts,
>  			     | SANITIZE_RETURNS_NONNULL_ATTRIBUTE))
>  	  opts->x_flag_delete_null_pointer_checks = 0;
>  
> +	/* UBSan and KASan enable recovery by default.  */
> +	opts->x_flag_sanitize_recover
> +	  = !!(flag_sanitize & (SANITIZE_UNDEFINED
> +				| SANITIZE_UNDEFINED_NONDEFAULT
> +				| SANITIZE_KERNEL_ADDRESS));
> +

Doesn't this override even user supplied -fsanitize-recover or
-fno-sanitize-recover ?  Have you tried both
-fno-sanitize-recover -fsanitize=kernel-address
and
-fsanitize=kernel-address -fno-sanitize-recover
option orders?

Seems for -fdelete-null-pointer-checks we got it wrong too,
IMHO for -fsanitize={null,{,returns-}nonnull-attribute,undefined}
we want to disable it unconditionally, regardless of whether
that option appears on the command line or not.
And we handle it right for 
-fdelete-null-pointer-checks -fsanitize=undefined
but not for
-fsanitize=undefined -fdelete-null-pointer-checks
Joseph, thoughts where to override it instead (I mean, after all
options are processed)?

In the -fsanitize-recover case, I'd on the other side think that
it should just override the default and not override explicit
user's decision.  Which could be done here, but supposedly guarded
with if (!opts_set->x_flag_sanitize_recover)?

I don't think your proposal will work properly though,
if one compiles with
-fsanitize=undefined -fsanitize=address
you'll just get userland asan with error recovery, which is highly
undesirable (not just that it changes the behavior from how it
behaved before, but especially because libasan doesn't contain
such entrypoints at all).
-fsanitize=undefined,address
or
-fsanitize=address,undefined
is normal supported mode and thus I think you either can't reuse
-fsanitize-recover option for what you want to do, or
asan.c needs to limit it to flag_sanitize & SANITIZE_KERNEL_ADDRESS
mode only.  Depends if you ever want to add recovery for userland
sanitization.

	Jakub

  reply	other threads:[~2014-09-18 10:53 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05  6:54 [PATCH] " Yury Gribov
2014-09-05  7:32 ` Dmitry Vyukov
2014-09-05  8:12   ` Yury Gribov
2014-09-05  8:23     ` Dmitry Vyukov
2014-09-05  8:33       ` Yury Gribov
2014-09-05  9:28         ` Jakub Jelinek
2014-09-05  9:32           ` Yury Gribov
2014-09-05  9:05 ` Andrey Ryabinin
2014-09-05  9:12   ` Yury Gribov
2014-09-15  9:38 ` [PATCH][PING] " Yury Gribov
2014-09-18 10:53   ` Jakub Jelinek [this message]
2014-09-18 13:14     ` Yury Gribov
2014-09-18 23:47     ` Joseph S. Myers
2014-09-29 17:21   ` [PATCHv3][PING] " Yury Gribov
2014-09-29 17:44     ` Jakub Jelinek
2014-09-29 21:20       ` Konstantin Serebryany
2014-09-29 22:37         ` Alexey Samsonov
     [not found]         ` <CAGSYnCPwbgZ++2Jt2vE6-ytveSJwSQPZT5umLeKPVWsVjWzwPQ@mail.gmail.com>
2014-09-29 23:17           ` Jakub Jelinek
2014-09-29 23:26             ` Alexey Samsonov
2014-09-30  0:24               ` Konstantin Serebryany
2014-09-30  1:05                 ` Alexey Samsonov
2014-09-30  1:49                   ` Konstantin Serebryany
2014-09-30  5:40                 ` Jakub Jelinek
2014-09-30  7:07                   ` Yury Gribov
2014-09-30 17:26                     ` Alexey Samsonov
2014-09-30 17:33                       ` Jakub Jelinek
2014-09-30 17:36                         ` Alexey Samsonov
2014-09-30 17:39                           ` Jakub Jelinek
2014-10-01 23:21                             ` Alexey Samsonov
2014-10-02  5:58                               ` Jakub Jelinek
2014-10-03 18:54                                 ` Alexey Samsonov
     [not found]                             ` <543BADAB.4090000@samsung.com>
2014-10-17 16:16                               ` [PATCH] -fsanitize-recover=list Jakub Jelinek
2014-10-20 10:44                                 ` Yury Gribov
2014-10-22  8:05                                 ` Yury Gribov
2014-10-22 10:02                                   ` Jakub Jelinek
2014-11-18  2:50                                 ` Alexey Samsonov
2014-11-18  7:27                                   ` Jakub Jelinek
2014-11-18  8:29                                     ` Alexey Samsonov
2014-11-18  8:34                                       ` Jakub Jelinek
2014-11-18 20:25                                         ` Alexey Samsonov
2014-12-19  2:47                                           ` Alexey Samsonov
2014-12-19  8:14                                             ` Jakub Jelinek
     [not found]                                               ` <CAGSYnCNLoU0p3FGDwb6mMAAOWFz2Te1m7wmWD94PhcADsQs9rQ@mail.gmail.com>
2015-01-05 17:40                                                 ` [PATCH] -f{no-sanitize,{,no-}sanitize-recover}=all support Jakub Jelinek
2015-01-05 20:32                                                   ` Jeff Law
2015-01-05 21:40                                                     ` Jakub Jelinek
2015-01-05 22:02                                                       ` Jakub Jelinek
2015-01-06  9:00                                                         ` Dodji Seketeli
2014-11-18  7:39                                   ` [PATCH] -fsanitize-recover=list Yury Gribov
2014-09-30  6:57                 ` [PATCHv3][PING] Enable -fsanitize-recover for KASan Yury Gribov
2014-09-30  7:14                   ` Yury Gribov
2014-10-23  7:15     ` [PATCHv4] " Yury Gribov
2014-10-23  7:20       ` Jakub Jelinek
2014-10-23  7:30         ` Yury Gribov
2014-10-23  9:55           ` Andrey Ryabinin
2014-10-23 10:00             ` Jakub Jelinek
2014-10-23 10:07               ` Jakub Jelinek
2014-10-23 10:24                 ` Andrey Ryabinin
2014-10-23 10:27                   ` Yury Gribov
2014-10-23 10:11               ` Andrey Ryabinin
2014-10-23 10:17                 ` Jakub Jelinek
2014-10-23 10:38                   ` Yury Gribov
2014-10-23 10:39                     ` Jakub Jelinek
2014-10-23 11:12                       ` Andrey Ryabinin
2014-10-24  8:37                         ` Yury Gribov
2014-10-24  9:46                           ` Dmitry Vyukov
2014-10-24  9:52                             ` Jakub Jelinek
2014-10-24  9:56                               ` Dmitry Vyukov
2014-10-24  9:59                               ` Jakub Jelinek
2014-10-24 10:01                             ` Yury Gribov
2014-10-24 10:21                               ` Dmitry Vyukov
2014-10-28  8:46       ` [PATCH v5] " Yury Gribov
2014-10-28  9:31         ` Jakub Jelinek
2014-10-28 10:15           ` Yury Gribov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140918105251.GD17454@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=a.ryabinin@samsung.com \
    --cc=dvyukov@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=k.khlebnikov@samsung.com \
    --cc=konstantin.s.serebryany@gmail.com \
    --cc=y.gribov@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).