Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9181322pxu; Mon, 28 Dec 2020 08:36:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoX+o6ZM56rtsdBGWhse/xk/B10gFflnQoYMeOEwHRPSjKAjCjJHxJHZKScty1SW05CkTA X-Received: by 2002:a17:907:2506:: with SMTP id y6mr42303427ejl.53.1609173369485; Mon, 28 Dec 2020 08:36:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173369; cv=none; d=google.com; s=arc-20160816; b=pP7miVy+l4zlGEvWG48IZoOszRmrdrCbdl0lprps02wJ/P4fWJPZtKXfxrdX9rAUCV fmRJUNuQ2qTNZWpPJA/iBVaKesZFObETY9j4o46mwqge8TBvYAvkirSyBtnIAHdJOerS xiHg5sCC4yczWjxvJ5e8OW0eaRMWBI7rf5zUwD2u6v7afUaG3+e+pgLXV3HqICkrNdEN zaMpbrXgl0BhoDeG7wTiPKyJsLGGOMRwpm0Ufv4qjNkDxn9kP9jLPzMIuKptZ54ziojO 7AQMEnG3vDGWUmkW7Wve5P8caVReTU3v5dqkQGYIiXfEzBOb3PwBfg2MTmZw9BB8b2Dk +7lQ== 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=AhaVAo64HB05pu9wfReb3Ov5L0oQzT3C1tY31XQMU+I=; b=vZunncyjCDbQbEtdG+ThBAr9AfhdRtQO1WrD3pw5dWwoCqndyz2qqjt5IEdzSvIOsZ IdnBZ6isaMDIPQ/VTuT7lIawJsH5mm/1XOni0KVRiaceBg4x/k0WtbGk6L9u/oXfBdvq icQKtnTx3LOqD+MvMCzuU62myKfiR0jstAoYvlvfhCa8bGf/3ijWBLcgAZeTBar/6ECF A/jJCHDtjEjsjoXTXn05OwaM9ZDYuH5CReRPRrNy4mnvZG6zE1LFWflCTjjsZqMH6gge wR+ioRbwpsR2xVXmfpjoBHyWmA0JPwZQwrhA1a+3WlJDcF1KG2gIbkhArrQsx1viOOO7 GSEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zy59Dwo0; 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 t6si21442583edt.513.2020.12.28.08.35.46; Mon, 28 Dec 2020 08:36:09 -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=Zy59Dwo0; 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 S2441897AbgL1QcQ (ORCPT + 99 others); Mon, 28 Dec 2020 11:32:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:60432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730398AbgL1NER (ORCPT ); Mon, 28 Dec 2020 08:04:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CE0DD22583; Mon, 28 Dec 2020 13:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160616; bh=S6MYLTteBd2F4CN61YD9SP2wyUzE9VfO13Em9rb6hzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zy59Dwo03RqfDVJr3ELFLIjS5CGYRQh9VmXskiTBLKfTt86MjGoc8DBE2GHEKjq1M geof+XM8rZHbEViVqg6EdiEPU6NkScTscVUdr8ycwcl9IhovbcB6lQgAAYVtDFMkEv JNaWhc5t7V/lTX27MDxfMVZXnHbY4nP8jAfyOiCo= 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.9 111/175] x86/kprobes: Restore BTF if the single-stepping is cancelled Date: Mon, 28 Dec 2020 13:49:24 +0100 Message-Id: <20201228124858.632467448@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 86aec286e4f22..3da08881a0104 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -1018,6 +1018,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