From: Martin Liska Date: Thu, 5 Jan 2017 09:16:50 +0000 (+0100) Subject: Do not sanitize in an abnormal context (PR sanitizer/78815). X-Git-Tag: basepoints/gcc-8~2009 X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=6ff92497174e84271f71d1a1ede8a0ec513ee6a7;p=gcc.git Do not sanitize in an abnormal context (PR sanitizer/78815). 2017-01-05 Martin Liska PR sanitizer/78815 * gimplify.c (gimplify_decl_expr): Compare to asan_poisoned_variables instread of checking flags. (gimplify_target_expr): Likewise. (gimplify_expr): Likewise. (gimplify_function_tree): Conditionally initialize asan_poisoned_variables. From-SVN: r244095 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 78b4412a0617..b9d6cb4d0ff5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-01-05 Martin Liska + + PR sanitizer/78815 + * gimplify.c (gimplify_decl_expr): Compare to + asan_poisoned_variables instread of checking flags. + (gimplify_target_expr): Likewise. + (gimplify_expr): Likewise. + (gimplify_function_tree): Conditionally initialize + asan_poisoned_variables. + 2017-01-04 Jeff Law PR tree-optimizatin/78812 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 14e79b4b3f35..e1e9ce9e9030 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1620,8 +1620,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p) is_vla = true; } - if (asan_sanitize_use_after_scope () - && !asan_no_sanitize_address_p () + if (asan_poisoned_variables && !is_vla && TREE_ADDRESSABLE (decl) && !TREE_STATIC (decl) @@ -6413,8 +6412,7 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) else cleanup = clobber; } - if (asan_sanitize_use_after_scope () - && dbg_cnt (asan_use_after_scope)) + if (asan_poisoned_variables && dbg_cnt (asan_use_after_scope)) { tree asan_cleanup = build_asan_poison_call_expr (temp); if (asan_cleanup) @@ -11426,7 +11424,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, /* If the label is used in a goto statement, or address of the label is taken, we need to unpoison all variables that were seen so far. Doing so would prevent us from reporting a false positives. */ - if (asan_sanitize_use_after_scope () + if (asan_poisoned_variables && asan_used_labels != NULL && asan_used_labels->contains (label)) asan_poison_variables (asan_poisoned_variables, false, pre_p); @@ -12531,10 +12529,14 @@ gimplify_function_tree (tree fndecl) && !needs_to_live_in_memory (ret)) DECL_GIMPLE_REG_P (ret) = 1; - asan_poisoned_variables = new hash_set (); + if (asan_sanitize_use_after_scope () && !asan_no_sanitize_address_p ()) + asan_poisoned_variables = new hash_set (); bind = gimplify_body (fndecl, true); - delete asan_poisoned_variables; - asan_poisoned_variables = NULL; + if (asan_poisoned_variables) + { + delete asan_poisoned_variables; + asan_poisoned_variables = NULL; + } /* The tree body of the function is no longer needed, replace it with the new GIMPLE body. */