From patchwork Fri Jun 20 10:04:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: max X-Patchwork-Id: 362142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 9B844140092 for ; Fri, 20 Jun 2014 20:04:43 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=DNVp2K+VjoNdsHHqqlgi05CVW1ODArpRJ9DvmiTDIlb biUXwMl3T/Pen4KTImDTOkFKEJMari9iG8Y4B6/g2ms0V6i7KdPbypEZbP0dtNl8 WSw6k4IUbcD9B55x1zUSalafRQURNwLM6I39QfMjfhxH4Yux+L8eElPnDVz9VdqM = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=gfh0aAC0z6dNfAlAWWf09QhZ8Jc=; b=G4N83WDtmQYPODKEj au5R4JV+06ItYexlRvrjELBc5JLAFobgCXa9G1XXDKsR0pNrGHRoAaXw+rN/ZACK u3RYr83WwrNqbbKuaAj12yLEO1Bk1M4TcNVGqaP5tMJ91Q7WHDDBx2yyzox9t2EA qszLqpAFo5wXgu7k/GKZ0AQIDI= Received: (qmail 31751 invoked by alias); 20 Jun 2014 10:04:36 -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 31735 invoked by uid 89); 20 Jun 2014 10:04:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_HDRS_LCASE, T_MANY_HDRS_LCASE, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailout3.w1.samsung.com Received: from mailout3.w1.samsung.com (HELO mailout3.w1.samsung.com) (210.118.77.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Fri, 20 Jun 2014 10:04:32 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N7G000K1PBECG10@mailout3.w1.samsung.com> for gcc-patches@gcc.gnu.org; Fri, 20 Jun 2014 11:04:26 +0100 (BST) Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 6A.22.27902.A2704A35; Fri, 20 Jun 2014 11:04:26 +0100 (BST) Received: from [106.109.8.30] by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N7G005N5PBDYI80@eusync1.samsung.com>; Fri, 20 Jun 2014 11:04:26 +0100 (BST) Message-id: <53A40729.2080702@partner.samsung.com> Date: Fri, 20 Jun 2014 14:04:25 +0400 From: Maxim Ostapenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-version: 1.0 To: GCC Patches Cc: Yuri Gribov , Slava Garbuzov , Jakub Jelinek Subject: [PATCH] Fix ICE in Asan Content-type: multipart/mixed; boundary=------------000206020401090409040305 X-IsSubscribed: yes Hi, This patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61530. Tested on x86_64-unknown-linux-gnu, no regressions. Ok to commit? -Maxim gcc/ChangeLog: 2014-06-20 Yury Gribov Max Ostapenko * asan.c (build_check_stmt): Add condition. gcc/testsuite/ChangeLog: 2014-06-20 Yury Gribov Max Ostapenko * c-c++-common/asan/pr61530.c: New test. diff --git a/gcc/asan.c b/gcc/asan.c index 281a795..4d87dad 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1654,6 +1654,7 @@ build_check_stmt (location_t location, tree base, tree len, if (size_in_bytes > 1) { if ((size_in_bytes & (size_in_bytes - 1)) != 0 + || !is_scalar_access || size_in_bytes > 16) size_in_bytes = -1; else if (align && align < size_in_bytes * BITS_PER_UNIT) diff --git a/gcc/testsuite/c-c++-common/asan/pr61530.c b/gcc/testsuite/c-c++-common/asan/pr61530.c new file mode 100644 index 0000000..e306a71 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr61530.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-shouldfail "asan" } */ + +__attribute__((noinline,noclone)) void +foo (char *a, char *b) { + a[0] = b[0] = 0; + __builtin_memcpy(a, b, 4); +} + +int +main () { + char a, b; + foo (&a, &b); + return 0; +} + +/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */