Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45b2b650 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Greg Kroah-Hartman
Browse files

x86/kprobes: Restore BTF if the single-stepping is cancelled



[ 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: 1ecc798c ("x86: debugctlmsr kprobes")
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/160389546985.106936.12727996109376240993.stgit@devnote2


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 28b4a8bc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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,