Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9045025pxu; Mon, 28 Dec 2020 05:17:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtDLfbSGjq1uMzRY77flSPIirheZ+diCXEwdPA85y/pkojawyxOVjzi4c3wiz2SDwPWDxe X-Received: by 2002:a17:906:98d4:: with SMTP id zd20mr41766928ejb.532.1609161447797; Mon, 28 Dec 2020 05:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161447; cv=none; d=google.com; s=arc-20160816; b=JebBwpBq3anFewvqeERzh5nSvhzLjdHUKimM266sPmjNXrsrKx4WlTYPHDiNRCF91l uKcXG+fOiieQ+KLGD4mzIjBgXYfEoOg79xLVXRMVwYYL65UAK/6Hx7ajnVFrlaylDRP0 TYncdxzUx/waJt67SC8s3BekLvTtpo9yC4whbaWr56q6O+ElNZ2Ie5vP/Xwuh6ZOwaNn qPyLhKdypaK8PZmO1uRfJX1g1r/d7MzcRY4c5AMFF91woyBr+Z2XcxNMJCny9VhFqr1B Vny9F8RFKdwYV9xv4ZZj37l7GhvpmdSqQprnHFLxMTNK79EDkeYrNkcGxp4qZa3FDpTG 6gNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/CvJbXp+Qlq0pUhEipQGmLwf/23Cd4DXQqqmQcsbG2k=; b=KxCV6OZ2dgG1Gxn300fxaXr0QNpctynk/tbpOBUaRgbCWpJKg2nWfZIL0gqH3obxgx cyXn/HSUu/mG/+ewX3KRlH4D4SHS2xYvFoHJ//0dobqW+76oZbkzf0Wg2cCuGjcql/ym eMOZyzegsng49acgTR7s8YFtzZcm3udn1+6NTiisunLYzYZSSuHbCThXZBruWHyQeuN5 dn1VVMfgzeGAyOeoEwijVTpLep6OC9qepUfLQGJaFa/9z8Le+i6IDxUAO1i5Ttb1LpqT cHyAdlr/zYdyW+O0TFD2CfI7f/8cg5N1Vba6NQ7n0pQINtiHKLdqbt+kg29eRXsGj4Uw 6Skw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QMjIMb66; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si18683660eja.479.2020.12.28.05.17.04; Mon, 28 Dec 2020 05:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QMjIMb66; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732521AbgL1NOg (ORCPT + 99 others); Mon, 28 Dec 2020 08:14:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:42382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbgL1NOb (ORCPT ); Mon, 28 Dec 2020 08:14:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADA8620728; Mon, 28 Dec 2020 13:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161256; bh=6gtKOBkROwMwHTq4kWxr4EcTFxSXOrjoyeR0cg87E/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QMjIMb660e97697jYbwJVsmVKWyJgB1bqXUwhfAacka6S4dmuFie+fJ+1ZgLPKI9X GUoEQHCVHKzz0WJQE+GldOuUeQFNvMhQ4rauTek7JzeHKgbTnucDJHko33PVa+aYsa FQGZVUFO/dAS705m9AaSaiHjfwFIFE0olnaQlmU8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 4.14 155/242] x86/kprobes: Restore BTF if the single-stepping is cancelled Date: Mon, 28 Dec 2020 13:49:20 +0100 Message-Id: <20201228124912.335225697@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit 78ff2733ff352175eb7f4418a34654346e1b6cd2 ] Fix to restore BTF if single-stepping causes a page fault and it is cancelled. Usually the BTF flag was restored when the single stepping is done (in resume_execution()). However, if a page fault happens on the single stepping instruction, the fault handler is invoked and the single stepping is cancelled. Thus, the BTF flag is not restored. Fixes: 1ecc798c6764 ("x86: debugctlmsr kprobes") Signed-off-by: Masami Hiramatsu Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/160389546985.106936.12727996109376240993.stgit@devnote2 Signed-off-by: Sasha Levin --- arch/x86/kernel/kprobes/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 02665ffef0506..700d434f5bda9 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -1022,6 +1022,11 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr) * So clear it by resetting the current kprobe: */ regs->flags &= ~X86_EFLAGS_TF; + /* + * Since the single step (trap) has been cancelled, + * we need to restore BTF here. + */ + restore_btf(); /* * If the TF flag was set before the kprobe hit, -- 2.27.0