This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC Asan instrumentation control
- From: Maxim Ostapenko <m dot ostapenko at partner dot samsung dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Yury Gribov <y dot gribov at samsung dot com>, Konstantin Serebryany <konstantin dot s dot serebryany at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Viacheslav Garbuzov <v dot garbuzov at samsung dot com>
- Date: Thu, 19 Dec 2013 15:59:28 +0400
- Subject: Re: RFC Asan instrumentation control
- Authentication-results: sourceware.org; auth=none
- References: <52A1B4F2 dot 8040105 at samsung dot com> <20131206120929 dot GJ892 at tucnak dot redhat dot com> <CAGQ9bdw4O9xF=-KKf8sX-iNVnzoy3=A_cmViEGTi98THEFWW0A at mail dot gmail dot com> <52A1C564 dot 3030505 at samsung dot com> <CAGQ9bdx9=T7jreZLTf2o=2PiSr1HAft-7E6nFrhyei59LV_Zag at mail dot gmail dot com> <52A1CCE0 dot 40307 at samsung dot com> <CAGQ9bdyyqqW0nibRHnqSCVe4XdahaipVQJBbKhFfEoAJLtUZ4w at mail dot gmail dot com> <52A1D1E3 dot 1040200 at samsung dot com> <52B18887 dot 9080605 at partner dot samsung dot com> <20131218115930 dot GX892 at tucnak dot redhat dot com>
2013-12-18 Max Ostapenko<m.ostapenko@partner.samsung.com>
* gcc/asan.c (asan_emit_stack_protection): Optionally disable
stack protection.
(instrument_derefs): Optionally disable memory access
instrumentation.
(instrument_mem_region_access): Likewise.
(instrument_strlen_call): Likewise.
(asan_finish_file): Optionally disable global variables protection.
* gcc/doc/invoke.texi: Added doc for new options.
* gcc/params.def: Added new options.
* gcc/params.h: Likewise.
> No gcc/ prefixes in ChangeLog entries.
Thanks, fixed.
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-builder.h"
#include "ubsan.h"
#include "predict.h"
+#include "params.h"
/* AddressSanitizer finds out-of-bounds and use-after-free bugs
with <2x slowdown on average.
@@ -963,6 +964,9 @@ rtx
asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
HOST_WIDE_INT *offsets, tree *decls, int length)
{
+ if (!ASAN_STACK)
+ return NULL_RTX;
> This is a wrong spot to do this. Instead put it into the
> if ((flag_sanitize & SANITIZE_ADDRESS) && pred)
> condition in cfgexpand.c (and maybe also
> if ((flag_sanitize & SANITIZE_ADDRESS) && isize != jsize ...)
> too, maybe all four flag_sanitize & SANITIZE_ADDRESS occurrences in
> cfgexpand.c.
Moved this check to cfgexpand.c.
@@ -2396,7 +2413,7 @@ asan_finish_file (void)
++gcount;
htab_t const_desc_htab = constant_pool_htab ();
htab_traverse (const_desc_htab, count_string_csts, &gcount);
- if (gcount)
+ if (gcount && ASAN_GLOBALS)
{
tree type = asan_global_struct (), var, ctor;
tree dtor_statements = NULL_TREE;
> I'd say this isn't sufficient, for !ASAN_GLOBALS you should also make
sure
> asan_protect_global always returns false, so that no extra padding is
emitted
> around the global vars.
Moved globals protection check to asan_protect_global.
> Talking about this, perhaps there should be also
> --param asan-use-after-return=0
> knob to disallow the support for use-after-return checking (in 4.8 this
> didn't exist, in 4.9 there is some extra runtime code emitted, but
still one
> needs to enable it manually through environment variable). With that
param
> we would emit pretty much what 4.8 did, i.e. assume that
use-after-return
> will not be enabled in the runtime.
Added this option and also implemented asan-memintrin option.
Is it OK?
-Maxim