diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2020-10-28 23:31:10 +0900 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2020-12-09 17:08:57 +0100 |
commit | 78ff2733ff352175eb7f4418a34654346e1b6cd2 (patch) | |
tree | 78de136fb9b5056b893f051ed195bea557741e74 /arch/x86 | |
parent | 78af4dc949daaa37b3fcd5f348f373085b4e858f (diff) |
x86/kprobes: Restore BTF if the single-stepping is cancelled
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 <mhiramat@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/160389546985.106936.12727996109376240993.stgit@devnote2
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/kprobes/core.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 547c7abb39f5..39f7d8c3c064 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, |