From patchwork Fri Mar 2 04:45:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 130464 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp864650lja; Thu, 1 Mar 2018 20:46:19 -0800 (PST) X-Google-Smtp-Source: AG47ELuE/cJ8liMq66Ajn/4ptK6jX2GvNRfdpSE00XvoAcLYGaZm6990iVgd3wQPvjVzcxx9S88Z X-Received: by 2002:a17:902:6b83:: with SMTP id p3-v6mr4088921plk.18.1519965979021; Thu, 01 Mar 2018 20:46:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519965979; cv=none; d=google.com; s=arc-20160816; b=b54QUWtl8QWuvsHRjQFRyB3s0p2xg7V/01kf/lFdPsXTOXByoBov5cvKOdhDRos4Me Ao3gV0r5Wda5skgw7og/ofkjhpp4rXvmhWinkVjxslvq+RVRrINRlh3yrNLH8Xc9gtY4 tIS7Et/HCQQluScwOzBz1U7o3fMSaJbnxsiZuU6I5dgbEKUlqQpPexR1+XaM/HysRb3J AmNEP/zE479eh/p4BY05TLG+dVHllKMSDKZODBop+1oNCTrGo3ccdRsWtxUdrFuTmigs JWQCjifIPT86imUEXsdNx2RFyPwjPThEVuATsLNZamByCsBbmGrxfvjYw1jN4GziC5WV P9Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TnoasaSlA/hMPN3jNew/BuhW6dofLf0ptLArgY4Q6CY=; b=EcNeFMB58LfJ59D38FaSCrLX04v832bMQ0j3Ac8iQQ9J5mxoxaAlYnVd6s9fTuRl0b WPb5kO/PuvV1XaMxPqKKWzygyTucUvtjoH4vNaWQfjXiaU2ZJ7e2O4wt1wiaRwiFnt88 E/ZT2nIk3VAadeiPeVakefNzrobLAg+1itbAgZoHAd4kE6D5Pgf9B/TmMUcyzeQsugC9 axXCM6Fyt2kZiqU0jt8ZW56dgoDjzgOYUs+SfG2FKsIJid0nb4CSdK9/HrYLc8h0MsKO nDZI54U/qXCNgxN1hUX2I2zU+vQtzJKU5loChg17xd4XitIreymx6Z9nQOhsPVkaaBck Xc4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si4168668pfl.304.2018.03.01.20.46.18; Thu, 01 Mar 2018 20:46:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164424AbeCBEqQ (ORCPT + 10 others); Thu, 1 Mar 2018 23:46:16 -0500 Received: from ozlabs.org ([103.22.144.67]:58739 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164937AbeCBEqE (ORCPT ); Thu, 1 Mar 2018 23:46:04 -0500 Received: by ozlabs.org (Postfix, from userid 1034) id 3zsxZg4x69z9sWw; Fri, 2 Mar 2018 15:46:03 +1100 (AEDT) From: Michael Ellerman To: Alexander.Levin@microsoft.com Cc: stable@vger.kernel.org, linuxppc-dev@ozlabs.org, npiggin@gmail.com Subject: [PATCH v4.1 backport 14/15] powerpc/ptrace: Fix out of bounds array access warning Date: Fri, 2 Mar 2018 15:45:48 +1100 Message-Id: <20180302044549.14930-15-mpe@ellerman.id.au> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180302044549.14930-1-mpe@ellerman.id.au> References: <20180302044549.14930-1-mpe@ellerman.id.au> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Khem Raj commit 1e407ee3b21f981140491d5b8a36422979ca246f upstream. gcc-6 correctly warns about a out of bounds access arch/powerpc/kernel/ptrace.c:407:24: warning: index 32 denotes an offset greater than size of 'u64[32][1] {aka long long unsigned int[32][1]}' [-Warray-bounds] offsetof(struct thread_fp_state, fpr[32][0])); ^ check the end of array instead of beginning of next element to fix this Signed-off-by: Khem Raj Cc: Kees Cook Cc: Michael Ellerman Cc: Segher Boessenkool Tested-by: Aaro Koskinen Acked-by: Olof Johansson Signed-off-by: Michael Ellerman --- arch/powerpc/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.1 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index f21897b42057..93f200f14e19 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -376,7 +376,7 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset, #else BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) != - offsetof(struct thread_fp_state, fpr[32][0])); + offsetof(struct thread_fp_state, fpr[32])); return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.fp_state, 0, -1); @@ -404,7 +404,7 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset, return 0; #else BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) != - offsetof(struct thread_fp_state, fpr[32][0])); + offsetof(struct thread_fp_state, fpr[32])); return user_regset_copyin(&pos, &count, &kbuf, &ubuf, &target->thread.fp_state, 0, -1);