From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4CA8C3A5A8 for ; Wed, 4 Sep 2019 18:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 768FA20870 for ; Wed, 4 Sep 2019 18:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567621446; bh=Axjq89hiNix4ExOqrgQ/7i6PpccM7JLmexMXOo6n7vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rAxr2MXpg5N8JFmfm8Iw2Dzp4biEUQRWYNHblqhk/iKNAprWsxPBI62YokEySeFZt FeTrPfejzC1aHeWax+2Vz7hom+u4V6xHwOPHGTpBKJqUL1+JNjyc0ULUzaZcghNl8q 9iZRHit5aCKdYIsmGZNnbBWAzM7LpZ5qlU1CBMGQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388676AbfIDSCG (ORCPT ); Wed, 4 Sep 2019 14:02:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388158AbfIDSCF (ORCPT ); Wed, 4 Sep 2019 14:02:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B857822CEA; Wed, 4 Sep 2019 18:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620124; bh=Axjq89hiNix4ExOqrgQ/7i6PpccM7JLmexMXOo6n7vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HCbGGEr7rPer+8xRXz29Cw0+DxjKwyHFno1eEfjgYdUzYc4NqQtaRB9QV/G79ZSE8 LCX8p0iL+rWqo28TklPBqJnUampJAQFMos40xBow57qWrLNzuOmJhhFgIT7FHMTA3f WqtpdQ2MrokfD4RN9m+pJbeARcv5GbrknrYNiFnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brad Spengler , Dianzhang Chen , Thomas Gleixner , bp@alien8.de, hpa@zytor.com Subject: [PATCH 4.9 83/83] x86/ptrace: fix up botched merge of spectrev1 fix Date: Wed, 4 Sep 2019 19:54:15 +0200 Message-Id: <20190904175310.951734823@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175303.488266791@linuxfoundation.org> References: <20190904175303.488266791@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Greg Kroah-Hartman I incorrectly merged commit 31a2fbb390fe ("x86/ptrace: Fix possible spectre-v1 in ptrace_get_debugreg()") when backporting it, as was graciously pointed out at https://grsecurity.net/teardown_of_a_failed_linux_lts_spectre_fix.php Resolve the upstream difference with the stable kernel merge to properly protect things. Reported-by: Brad Spengler Cc: Dianzhang Chen Cc: Thomas Gleixner Cc: Cc: Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/ptrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -651,11 +651,10 @@ static unsigned long ptrace_get_debugreg { struct thread_struct *thread = &tsk->thread; unsigned long val = 0; - int index = n; if (n < HBP_NUM) { + int index = array_index_nospec(n, HBP_NUM); struct perf_event *bp = thread->ptrace_bps[index]; - index = array_index_nospec(index, HBP_NUM); if (bp) val = bp->hw.info.address;