From patchwork Thu Apr 20 12:49:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Fortune X-Patchwork-Id: 752789 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 3w7zH22r5Fz9s7L for ; Thu, 20 Apr 2017 22:50:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jeOfuVB8"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=YhX E2IXLLAaFUfHYYY4X6ucEFy3cgthHMjURTUkkO4YmDzgX6s7AIT0WkAzP+fNHZCD 55r0stClT7ZQERAMKf8xEfCWGURRdp+K2iNAoRmnVi+RWWgnL1AUQPADIGKGc6vL GeXrKbEJXaOGhq/RG+BOT644d9d19cpvAosaVu/E= 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 :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=HRzBU4Y+9 V9n5FZ23DKFLpiDNb4=; b=jeOfuVB83Bvkibl5goWWYSAOFr0i65teaE6a9/vpY VMJc93gINL1Kd8voOU8QWVB2GX42wl0mzMFU6TVim2Q8FtvJXvr+EK5FV8MaG+Ve +yqoDbJ0OKiSPPpNuaGqSx/Sd6MVhIBcNG1R0BFKcZoInAxmHee7EnDYCoSi7EAq QY= Received: (qmail 85472 invoked by alias); 20 Apr 2017 12:49:54 -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 85354 invoked by uid 89); 20 Apr 2017 12:49:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=vacation, overly, D*ru X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Apr 2017 12:49:51 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 2772B656B7AED; Thu, 20 Apr 2017 13:49:47 +0100 (IST) Received: from HHMAIL01.hh.imgtec.org ([fe80::710b:f219:72bc:e0b3]) by hhmail02.hh.imgtec.org ([fe80::5400:d33e:81a4:f775%25]) with mapi id 14.03.0294.000; Thu, 20 Apr 2017 13:49:50 +0100 From: Matthew Fortune To: "Jeff Law (law@redhat.com)" , "'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org)" CC: "jakub@redhat.com" Subject: [PATCH] MIPS: Prevent buffer overrun in uninitialised variable fix Date: Thu, 20 Apr 2017 12:49:49 +0000 Message-ID: <6D39441BF12EF246A7ABCE6654B0235380C0761B@HHMAIL01.hh.imgtec.org> MIME-Version: 1.0 X-IsSubscribed: yes Hi Jeff, I missed a load of test failures while on vacation and just noticed that the fix you did for a potentially uninitialized variable warning is overwriting the stack and breaking MSA in MIPS. I guess you may have intended to set the length appropriately and only zero the elements that would not be set in the loop: memset (&orig_perm[nelt], 0, MAX_VECT_LEN - nelt); but I switched it to just zero initialise the whole array for simplicity in the patch below. I thought I'd check with you before committing. Obviously I'd like to apply this to GCC 7 branch as well. Thanks, Matthew gcc/ * config/mips/mips.c (mips_expand_vec_perm_const): Re-fix uninitialized variable warning to avoid buffer overrun. --- gcc/ChangeLog | 5 +++++ gcc/config/mips/mips.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c908048..80d3436 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-04-20 Matthew Fortune + + * config/mips/mips.c (mips_expand_vec_perm_const): Re-fix + uninitialized variable warning to avoid buffer overrun. + 2017-04-20 Alexander Monakov PR other/71250 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index b35fba7..6bfd86a 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -21358,7 +21358,7 @@ mips_expand_vec_perm_const (rtx operands[4]) /* This is overly conservative, but ensures we don't get an uninitialized warning on ORIG_PERM. */ - memset (&orig_perm[nelt], 0, MAX_VECT_LEN); + memset (orig_perm, 0, MAX_VECT_LEN); for (i = which = 0; i < nelt; ++i) { rtx e = XVECEXP (sel, 0, i);