From patchwork Thu Jan 5 08:42:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 89958 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8866335qgi; Thu, 5 Jan 2017 00:43:21 -0800 (PST) X-Received: by 10.99.102.69 with SMTP id a66mr130295086pgc.49.1483605801891; Thu, 05 Jan 2017 00:43:21 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 3si75300312plx.43.2017.01.05.00.43.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2017 00:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445426-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445426-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445426-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=t3+dosr4sMjWAHHgu 29kcrd885AOjHH6zw5rvrOhLevDL9Ss+6ugf0uMo3+S+17vEa/nSnTq8ry14gCw3 mKyi6hknUKCM7L0CsLcUNP4o+/qnxz38tIaZPgaRF3fKLcU4RgtLJ5T27pj5d+9y zzzvb8yebjkIy/NSjyFrPet/1A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=WbGCfa1DOQH0G6r0MqbJJ/n Is0M=; b=VyrV0rUAGB5AewruQ3Pi/r3+kJVByfTPXPlp5BKGFXT2DEk29IaGyaQ vFzyv6gIxIo2nkAfuF3yIC6rvonZmdxz7rxZmt3UGAmmieQ12CdThI1Nuo2xb1c3 chxSo2g/goQmymcB7xVtV1F1UxOvC1kJ/eikUAwzx5ARuNUeZMB0= Received: (qmail 53065 invoked by alias); 5 Jan 2017 08:43:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 53047 invoked by uid 89); 5 Jan 2017 08:43:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jan 2017 08:42:58 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B2C17ABF5; Thu, 5 Jan 2017 08:42:56 +0000 (UTC) Subject: Re: [PATCH] Do not sanitize in lower_omp_target context (PR, sanitizer/78815). To: Jakub Jelinek References: <520dceec-1ca4-c0e1-0466-bbc0b1d4e9a7@suse.cz> <20170104093127.GG21933@tucnak> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <04ab26ff-8e08-ec38-792c-57a57e5edfc8@suse.cz> Date: Thu, 5 Jan 2017 09:42:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170104093127.GG21933@tucnak> X-IsSubscribed: yes On 01/04/2017 10:31 AM, Jakub Jelinek wrote: > On Wed, Jan 04, 2017 at 10:19:28AM +0100, Martin Liška wrote: >> PING^1 >> >> On 12/16/2016 01:04 PM, Martin Liška wrote: >>> Currently, use-after-scope relies on fact that entry point of gimplify_decl_expr >>> is gimplify_function_tree. Fixed by checking if asan_poisoned_variables is non-null. >>> >>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. >>> >>> Ready to be installed? > > Looking at asan_poisoned_variables, my preference would be to guard: > asan_poisoned_variables = new hash_set (); > with > if (asan_sanitize_use_after_scope () > && !asan_no_sanitize_address_p ()) > the delete asan_poisoned_variables; with if (asan_poisoned_variables) > and all the poisoning stuff in the gimplifier also with if > (asan_poisoned_variables) and no need to repeat there the asan_sanitize_use_after_scope > () and !asan_no_sanitize_address_p () tests. > if (asan_poisoned_variables != NULL > && asan_poisoned_variables->contains (t)) > is already fine, > if (asan_sanitize_use_after_scope () > && !asan_no_sanitize_address_p () > && !is_vla > && TREE_ADDRESSABLE (decl) > && !TREE_STATIC (decl) > && !DECL_HAS_VALUE_EXPR_P (decl) > && dbg_cnt (asan_use_after_scope)) > should replace the first 2 conditions with asan_poisoned_variables, > if (asan_sanitize_use_after_scope () > && asan_used_labels != NULL > && asan_used_labels->contains (label)) > asan_poison_variables (asan_poisoned_variables, false, pre_p); > should replace asan_sanitize_use_after_scope () with > asan_poisoned_variables. IMHO no need to add comments, especially not one > mentioning omp lowering - the gimplifier is called from lots of various > places. > > Jakub > I like your approach, I'm sending updated patch which bootstraps and survives regression tests. Ready to be installed? Martin >From 42887cf5fe7d94709ee5356fb6534c7a4fc26bff Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 4 Jan 2017 16:43:49 +0100 Subject: [PATCH] Do not sanitize in an abnormal context (PR sanitizer/78815). gcc/ChangeLog: 2017-01-04 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. --- gcc/gimplify.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 14e79b4b3f3..e1e9ce9e903 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. */ -- 2.11.0