Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9088217pxu; Mon, 28 Dec 2020 06:20:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8CvEIhja/S53/GP5xyyztLzgW9UdlE/as+IpK/TkCg8BWC6PoVEYsSN/v0JsU2R9WoZ+B X-Received: by 2002:a17:906:4985:: with SMTP id p5mr32908341eju.513.1609165235831; Mon, 28 Dec 2020 06:20:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165235; cv=none; d=google.com; s=arc-20160816; b=VpNwiv2U9Mg2+VfjBsVgaqdOe7hG21RKZCrbH+9QDugM69GTqH4hytwRjRWEs5DTRq oJk8BReOShA4pUbjolfuB1gAnPj1kdzpGFWtaR9cu14iuDC5x+jSE3Nt8dLRrMRBHINN ZQBY3FCH/AMvk8FZit/MtGdzXFJemxepq9rAE5CQ/L7n3nPrsyz/rfRaqxfes7lynD1Z iUErZmonSK4Krt6acc125VjO4VW+Ui5nMiWYLTyyxRjgvFaUNfRRWfRS298PJmQE8rbf ksUt74JtXO9ylulYF5bA5VYNznkGuTvDXg/xSi4h6NItUk61drg1fNAvEuGw+B+oSHUw +IGg== 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=BfOCCFLa3K9tls9fNjhE2bBe2lQIlQvj5z27FJqMlsI=; b=uHr+VpIwwkm5+PluTO+DD+D9LxACZH7ldJbmSGsU/dh6zKQuFvr+nLxB1Yh4MThij9 7Acsnpg2FqbJTII9dd/FYXb5KEadGKoJGatIWO9+Fq9OKE9At36X/EE7s/2Dsssd0fhJ JaJ6Pfbqp7U3/hfLI0BIeyYoE0TjkSU1XHe8DNx3zABPtUKoIaGGr/25RPg3PfxFp1ks Q4wOpv7+gwfgWjMPjHsXCenW0j2KNslvJX0VfDtg3WmXTVaU9V4ZK3kNAP30Ac7XvBvj 2yLzUUJScuyEOufXrx8oAiaVNXf84QJx2ViM4Caa+jaPyuiylkb7AshGjoHC6VaDqq4K Z4RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=c+yrGuvQ; 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 a5si17749592ejj.142.2020.12.28.06.20.11; Mon, 28 Dec 2020 06:20:35 -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=c+yrGuvQ; 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 S2389595AbgL1OSe (ORCPT + 99 others); Mon, 28 Dec 2020 09:18:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:53160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2501952AbgL1OS0 (ORCPT ); Mon, 28 Dec 2020 09:18:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD1202245C; Mon, 28 Dec 2020 14:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165085; bh=2WvY5f03cvQy4xUZwAWoi107DIC22ZBcmbic3ZzcDHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+yrGuvQ29IxRaXzgGN1DOpfw1rrc8jPGZNm2L5YJPZJWzeMQ7jQchO4aFApoohxJ W3mBpendjx5lgv6IyFCQ5ybEtGSD1dvWaCkj3V+F7UtG3fuSDjEIQJQs2QfDbBWSkk PF+3MBs7GxvDzjObN57Eb0h12JtkpoaZM4DXucF4= 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.10 378/717] x86/kprobes: Restore BTF if the single-stepping is cancelled Date: Mon, 28 Dec 2020 13:46:16 +0100 Message-Id: <20201228125039.119863260@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 547c7abb39f51..39f7d8c3c064b 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -937,6 +937,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