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=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 9C4BBC4363A for ; Tue, 27 Oct 2020 22:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42694221FB for ; Tue, 27 Oct 2020 22:19:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LkeuqJm0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bTWhHCUo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832268AbgJ0WTO (ORCPT ); Tue, 27 Oct 2020 18:19:14 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49630 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1832242AbgJ0WTN (ORCPT ); Tue, 27 Oct 2020 18:19:13 -0400 Date: Tue, 27 Oct 2020 22:19:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603837150; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QV72nsyiNi0RQVNKjT187iZMxP5cFj3WeywmE2OqgAs=; b=LkeuqJm0KrpyhCTIs3DuzSlcbUeCz61xMSXC5YWifcl3dF+hT1INq6jEieljEIDqtAchBw kmU3ebKpfgqW1azcLsW+uOsowRcWmVQC9iYI8+4AY2snHKhqt6uGeCCmV+7L1VRTwvxIL1 gDtmK23wYLhsSTL3csD4tdQ/9VTyTQx+Lm/3eTIiZN8mNieKjA9/4P/Gfwz5MNiOGwpK48 K6AGf//QfNiwHPqMpAUXQN4y08DiVEHC/bX4kQ0Fe0rn3bhMQiLjz0H4p4TVwru9VKyHpJ D1uIlGjhNzXPeFLpcyQSZQM12Pz7/U/ONBCRECvJzDSJc2XVMv/JdEtnjebX8A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603837150; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QV72nsyiNi0RQVNKjT187iZMxP5cFj3WeywmE2OqgAs=; b=bTWhHCUov9+Rf4iVXuCmoeCDpJWvYs/gCNYJwOX6Dwk1gnxWhKJYFnXUVDgtD3KGw4YcyM aHCAqGLyPqPeSACw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/debug: Only clear/set ->virtual_dr6 for userspace #DB Cc: "Peter Zijlstra (Intel)" , Thomas Gleixner , Kyle Huey , x86 , LKML In-Reply-To: <20201027093608.028952500@infradead.org> References: <20201027093608.028952500@infradead.org> MIME-Version: 1.0 Message-ID: <160383715005.397.4679134647227236896.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: a195f3d4528a2f88d6f986f6b1101775ad4891cf Gitweb: https://git.kernel.org/tip/a195f3d4528a2f88d6f986f6b1101775ad4891cf Author: Peter Zijlstra AuthorDate: Tue, 27 Oct 2020 10:15:06 +01:00 Committer: Thomas Gleixner CommitterDate: Tue, 27 Oct 2020 23:15:23 +01:00 x86/debug: Only clear/set ->virtual_dr6 for userspace #DB The ->virtual_dr6 is the value used by ptrace_{get,set}_debugreg(6). A kernel #DB clearing it could mean spurious malfunction of ptrace() expectations. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Tested-by: Kyle Huey Link: https://lore.kernel.org/r/20201027093608.028952500@infradead.org --- arch/x86/kernel/traps.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index b5208aa..32b2d39 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -793,12 +793,6 @@ static __always_inline unsigned long debug_read_clear_dr6(void) set_debugreg(DR6_RESERVED, 6); dr6 ^= DR6_RESERVED; /* Flip to positive polarity */ - /* - * Clear the virtual DR6 value, ptrace routines will set bits here for - * things we want signals for. - */ - current->thread.virtual_dr6 = 0; - return dr6; } @@ -943,6 +937,12 @@ static __always_inline void exc_debug_user(struct pt_regs *regs, instrumentation_begin(); /* + * Clear the virtual DR6 value, ptrace() routines will set bits here + * for things it wants signals for. + */ + current->thread.virtual_dr6 = 0; + + /* * The SDM says "The processor clears the BTF flag when it * generates a debug exception." Clear TIF_BLOCKSTEP to keep * TIF_BLOCKSTEP in sync with the hardware BTF flag.