From patchwork Mon Aug 27 13:00:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 962502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-484496-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VVkzQAI/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41zX7j2Wlkz9s47 for ; Mon, 27 Aug 2018 23:01:05 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=QQv6JlmdjwHECLgBc4+WCHSRxQKJvMMQN7VaH36SvnXf0fiHtW +WdcMwr1dnBhXsc2Pw4mn92jdZ30w+efD2a+Bf9oFfRLVS3tUNvocgKWthMsVZkO aEHHRbmyiapcQ7Y5Na6vR1SwGbrnxsH7a8LOsscc2L01fxSbxv2d+pJFc= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=++9KmRPkU3T5WFKnRBlLPzuphPY=; b=VVkzQAI/dN44ETshhd10 urvzn+mWjlrHt43Y0kwm0Ge++XSqiE/vKCEk63vBdaC/2WfX1OIrvPEhlsSXOJTR WJQcB/unpXdfF+naI02PKHzKcY71ksGLePizx9AywnhamsISvwWdJSb2OroJfB4L ZgEhAg88iG9pLl/yxKCVJ+8= Received: (qmail 84527 invoked by alias); 27 Aug 2018 13:00:55 -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 59233 invoked by uid 89); 27 Aug 2018 13:00:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=rewriting X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Aug 2018 13:00:26 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D0E04AFC6; Mon, 27 Aug 2018 13:00:18 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Sanopt: ignore params with DECL_HAS_VALUE_EXPR_P (PR sanitizer/86962). To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek Message-ID: <04eebc30-8dfd-0170-0e6d-7833f09ef4a0@suse.cz> Date: Mon, 27 Aug 2018 15:00:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hello. In case of nested functions it may happen that we end up with a PARAM_DECL with DECL_HAS_VALUE_EXPR_P. If would skip these. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin gcc/ChangeLog: 2018-08-16 Martin Liska PR sanitizer/86962 * sanopt.c (sanitize_rewrite_addressable_params): Ignore params with DECL_HAS_VALUE_EXPR_P. gcc/testsuite/ChangeLog: 2018-08-16 Martin Liska PR sanitizer/86962 * gcc.dg/asan/pr86962.c: New test. --- gcc/sanopt.c | 6 ++++-- gcc/testsuite/gcc.dg/asan/pr86962.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr86962.c diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 223c06a8355..082f936adb5 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -1165,13 +1165,15 @@ sanitize_rewrite_addressable_params (function *fun) gimple_add_tmp_var (var); + /* We skip parameters that have a DECL_VALUE_EXPR. */ + if (DECL_HAS_VALUE_EXPR_P (arg)) + continue; + if (dump_file) fprintf (dump_file, "Rewriting parameter whose address is taken: %s\n", IDENTIFIER_POINTER (DECL_NAME (arg))); - gcc_assert (!DECL_HAS_VALUE_EXPR_P (arg)); - SET_DECL_PT_UID (var, DECL_PT_UID (arg)); /* Assign value of parameter to newly created variable. */ diff --git a/gcc/testsuite/gcc.dg/asan/pr86962.c b/gcc/testsuite/gcc.dg/asan/pr86962.c new file mode 100644 index 00000000000..7a8cfa98f0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr86962.c @@ -0,0 +1,13 @@ +/* PR sanitizer/86962 */ +/* { dg-do compile } */ + +extern int dummy (int *); + +void foo(int i) +{ + int j=i; + + void bar() { int x=j, y=i; } + + dummy(&i); +}