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 C4383C3A5A8 for ; Wed, 4 Sep 2019 18:22:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A136022CEA for ; Wed, 4 Sep 2019 18:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567621351; bh=AlYrLLd2/oNTqAUY81/sN6/lWfyg0HvsynexbqdfeLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=T3snBRn57ugew992B4dfBQ7yxmgwh9BFdjx8zvlPOBbJR16dnI3V8FYVC1Za/QUqY /tI5h30Pzwb+wPmdDRx06DNehy8aW9BXje+xrjYHZkR1H2/iPp9vnV40wE0BiELGWp bNxl4o/rk9XBSCHAXXFgnjddSt2/CO4G4d06mi24= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388536AbfIDSEm (ORCPT ); Wed, 4 Sep 2019 14:04:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:45780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389117AbfIDSEj (ORCPT ); Wed, 4 Sep 2019 14:04:39 -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 2E71D206BA; Wed, 4 Sep 2019 18:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620278; bh=AlYrLLd2/oNTqAUY81/sN6/lWfyg0HvsynexbqdfeLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iE4Yfawh76dePGnlD7h8yAgdSu6diNTqgo6Psi4usPlrn1Um4KEFEFZXyTwgVjZxO bM/eHhba7wQqR5y15lwO2CaEvwiPKMaUpAbfp3xa0tdkU5takLVjgw8mA3unJw3DnS n/sYD4Iu7GThuelLmtOLa3z4z755vl5rWxP9RlEs= 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.14 57/57] x86/ptrace: fix up botched merge of spectrev1 fix Date: Wed, 4 Sep 2019 19:54:25 +0200 Message-Id: <20190904175307.682768555@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@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 @@ -652,11 +652,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;