original_kernel/arch/arm64/kernel
Masami Hiramatsu b3980e4852 arm64: kprobes: Recover pstate.D in single-step exception handler
kprobes manipulates the interrupted PSTATE for single step, and
doesn't restore it. Thus, if we put a kprobe where the pstate.D
(debug) masked, the mask will be cleared after the kprobe hits.

Moreover, in the most complicated case, this can lead a kernel
crash with below message when a nested kprobe hits.

[  152.118921] Unexpected kernel single-step exception at EL1

When the 1st kprobe hits, do_debug_exception() will be called.
At this point, debug exception (= pstate.D) must be masked (=1).
But if another kprobes hits before single-step of the first kprobe
(e.g. inside user pre_handler), it unmask the debug exception
(pstate.D = 0) and return.
Then, when the 1st kprobe setting up single-step, it saves current
DAIF, mask DAIF, enable single-step, and restore DAIF.
However, since "D" flag in DAIF is cleared by the 2nd kprobe, the
single-step exception happens soon after restoring DAIF.

This has been introduced by commit 7419333fa1 ("arm64: kprobe:
Always clear pstate.D in breakpoint exception handler")

To solve this issue, this stores all DAIF bits and restore it
after single stepping.

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Fixes: 7419333fa1 ("arm64: kprobe: Always clear pstate.D in breakpoint exception handler")
Reviewed-by: James Morse <james.morse@arm.com>
Tested-by: James Morse <james.morse@arm.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
2019-08-02 11:55:50 +01:00
..
probes arm64: kprobes: Recover pstate.D in single-step exception handler 2019-08-02 11:55:50 +01:00
vdso arm64: vdso: Cleanup Makefiles 2019-07-22 10:37:33 +01:00
vdso32 arm64: vdso: Cleanup Makefiles 2019-07-22 10:37:33 +01:00
.gitignore
Makefile arm64: vdso: Enable vDSO compat support 2019-06-22 21:21:09 +02:00
acpi.c arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
acpi_numa.c
acpi_parking_protocol.c
alternative.c
armv8_deprecated.c
asm-offsets.c arm64: vdso: Remove unnecessary asm-offsets.c definitions 2019-06-26 07:28:10 +02:00
cacheinfo.c arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
cpu-reset.S
cpu-reset.h
cpu_errata.c arm64: KVM: Propagate full Spectre v2 workaround state to KVM guests 2019-07-05 13:56:27 +01:00
cpu_ops.c
cpufeature.c arm64: cpufeature: Fix feature comparison for CTR_EL0.{CWG,ERG} 2019-07-31 18:10:55 +01:00
cpuidle.c
cpuinfo.c arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
crash_core.c
crash_dump.c
debug-monitors.c arm64: Remove unneeded rcu_read_lock from debug handlers 2019-08-01 15:00:27 +01:00
efi-entry.S
efi-header.S
efi-rt-wrapper.S
efi.c mm/pgtable: drop pgtable_t variable from pte_fn_t functions 2019-07-12 11:05:46 -07:00
entry-fpsimd.S
entry-ftrace.S
entry.S arm64: entry: SP Alignment Fault doesn't write to FAR_EL1 2019-07-22 16:22:34 +01:00
fpsimd.c arm64/sve: Fix a couple of magic numbers for the Z-reg count 2019-07-22 11:49:03 +01:00
ftrace.c
head.S
hibernate-asm.S
hibernate.c
hw_breakpoint.c arm64: hw_breakpoint: Fix warnings about implicit fallthrough 2019-07-29 11:59:15 +01:00
hyp-stub.S
image.h arm64 fixes for 5.2 2019-07-03 15:57:30 +08:00
insn.c
io.c
irq.c arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
jump_label.c
kaslr.c
kexec_image.c
kgdb.c
kuser32.S docs: arm: convert docs to ReST and rename to *.rst 2019-07-15 09:20:24 -03:00
machine_kexec.c
machine_kexec_file.c
module-plts.c
module.c arm64: module: Mark expected switch fall-through 2019-07-29 11:59:36 +01:00
module.lds
paravirt.c
pci.c pci-v5.3-changes 2019-07-15 20:44:49 -07:00
perf_callchain.c arm64: stacktrace: Factor out backtrace initialisation 2019-07-22 11:44:08 +01:00
perf_event.c
perf_regs.c
pointer_auth.c
process.c arm64: Force SSBS on context switch 2019-07-22 15:24:16 +01:00
psci.c
ptrace.c arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
reloc_test_core.c
reloc_test_syms.S
relocate_kernel.S
return_address.c arm64: unwind: Prohibit probing on return_address() 2019-08-01 15:00:26 +01:00
sdei.c
setup.c arm64: move jump_label_init() before parse_early_param() 2019-07-12 11:05:46 -07:00
signal.c
signal32.c arm64: compat: Get sigreturn trampolines from vDSO 2019-06-22 21:21:09 +02:00
sigreturn32.S
sleep.S
smccc-call.S
smp.c arm64: smp: Mark expected switch fall-through 2019-07-29 11:59:30 +01:00
smp_spin_table.c
ssbd.c
stacktrace.c arm64: unwind: Prohibit probing on return_address() 2019-08-01 15:00:26 +01:00
suspend.c
sys.c
sys32.c
sys_compat.c
syscall.c
time.c arm64: stacktrace: Factor out backtrace initialisation 2019-07-22 11:44:08 +01:00
topology.c
trace-events-emulation.h
traps.c arm64: stacktrace: Factor out backtrace initialisation 2019-07-22 11:44:08 +01:00
vdso.c arm64: compat: VDSO setup for compat layer 2019-06-22 21:21:08 +02:00
vmlinux.lds.S