summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJisheng Zhang <Jisheng.Zhang@synaptics.com>2021-04-12 17:41:01 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-28 13:41:50 +0200
commit569df2316993d8485c10da9dc7b024321124c95a (patch)
treef47a5c0d85c741e0dc244ef0582a6c39e65142e4
parenteaabcb715243be5c7db0613e532a697732825a40 (diff)
downloadlinux-stable-569df2316993d8485c10da9dc7b024321124c95a.tar.gz
linux-stable-569df2316993d8485c10da9dc7b024321124c95a.tar.bz2
linux-stable-569df2316993d8485c10da9dc7b024321124c95a.zip
arm64: kprobes: Restore local irqflag if kprobes is cancelled
[ Upstream commit 738fa58ee1328481d1d7889e7c430b3401c571b9 ] If instruction being single stepped caused a page fault, the kprobes is cancelled to let the page fault handler continue as a normal page fault. But the local irqflags are disabled so cpu will restore pstate with DAIF masked. After pagefault is serviced, the kprobes is triggerred again, we overwrite the saved_irqflag by calling kprobes_save_local_irqflag(). NOTE, DAIF is masked in this new saved irqflag. After kprobes is serviced, the cpu pstate is retored with DAIF masked. This patch is inspired by one patch for riscv from Liao Chang. Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Link: https://lore.kernel.org/r/20210412174101.6bfb0594@xhacker.debian Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/arm64/kernel/probes/kprobes.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 66aac2881ba8..85645b2b0c7a 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -267,10 +267,12 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
if (!instruction_pointer(regs))
BUG();
- if (kcb->kprobe_status == KPROBE_REENTER)
+ if (kcb->kprobe_status == KPROBE_REENTER) {
restore_previous_kprobe(kcb);
- else
+ } else {
+ kprobes_restore_local_irqflag(kcb, regs);
reset_current_kprobe();
+ }
break;
case KPROBE_HIT_ACTIVE: