Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9272861pxu; Mon, 28 Dec 2020 11:03:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzv+wHfTgN6mFBpMVm6IX6Htd+KR2RUh4aKTLDURhUsqUGX/AQKNI7G2lZd4PPi1GolZN+G X-Received: by 2002:a17:906:3b55:: with SMTP id h21mr43051150ejf.184.1609182207593; Mon, 28 Dec 2020 11:03:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609182207; cv=none; d=google.com; s=arc-20160816; b=lntuWTQQG06/olm78obguc52dAF9cIIvMaZmfmxtz9p0d1JWaRY1xWWdSiuFeObgE1 I8cf3tvcguYsqFwYWibWHfPzkXfHKRNIOL7hqDoheQ+tw+OYPZBnHWpp1OAQ2vRWggU6 2IrbVPqbaoRr8ZgH94VUXBM8j/xps8Or5RDgQRBvXrAot/boRFBhKeIsuffVOoak58RZ YwM1e+x22QDcaCNkwOrBExMYsdzCaNn+pYBhJSsXRXvObjH/+w5g7uWOvtOeVOv3U0WC 7B3Wa9IeFU13ilI5gK6Tg+DAz9W50h/ccqH72YcUzR/lxW7PMU3cj4R7yyOXh5JMQcZf OhYA== 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=V3UI0kkay9QTrGAIHUeTmCwAQC3jOuh4eEVRz9JDdLQ=; b=A/Eq29WE3xKFDW/2qgvZdLgJV7FXH//VLFkp2jvfOd1+OZq8GbooiRNhHPXZQXMMYe RQIaR2AHhfdpKBPgsX8ACWv7jII+FhsM2+8z0agtPQRE+vEB8+lxq6sjiSyURPBn51dS YtuOf4xITqq4F4gpxC0zTcgA1Qc42AkAOyu4ZFpkeRRqryKYCZYuRufqHK8kKkkRVvLy O1kW2oB/Wfcj3z9LA6luy4wPNxAu8Wvw3+OZ6SfgxzG9GDZTenFUDw5q4kkp4JmFRoNa jGM0nVj+hieHux7HQTb6ERKDBulBWLRxLEGSsf5dq1NggFBNHOJo46BiHAwwtcOSpoYp Y8fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U6I+Zg9m; 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 v24si11242431eda.114.2020.12.28.11.03.05; Mon, 28 Dec 2020 11:03: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=U6I+Zg9m; 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 S2406229AbgL1Nty (ORCPT + 99 others); Mon, 28 Dec 2020 08:49:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:51614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406216AbgL1Ntu (ORCPT ); Mon, 28 Dec 2020 08:49:50 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 783F52064B; Mon, 28 Dec 2020 13:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609163350; bh=8EGLseDchkl6v2bDPaXrx+vIuUkblSXJmmhu5YI6sFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6I+Zg9mDUNCQhyBRIQOKCoZ89tD/oLOGSR2FzNh6kC7aD55uugdtIclHTroP/1ON FyvJsxeUCwPCNrf5GrNbywEAFhmnchYMOKq/4n8uX8p210rc1csgipAgyUbKOq6dxJ TWAPj0dpZUavo4fuGvQDwTpEz1Wzd3TGAShms7ck= 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 5.4 255/453] x86/kprobes: Restore BTF if the single-stepping is cancelled Date: Mon, 28 Dec 2020 13:48:11 +0100 Message-Id: <20201228124949.498448870@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@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 62c39baea39e3..5294018535d0c 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -1019,6 +1019,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