This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC Asan instrumentation control



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]