]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.117/arm64-only-advance-singlestep-for-user-instruction-traps.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.14.117 / arm64-only-advance-singlestep-for-user-instruction-traps.patch
CommitLineData
2913b778
GKH
1From 9478f1927e6ef9ef5e1ad761af1c98aa8e40b7f5 Mon Sep 17 00:00:00 2001
2From: Mark Rutland <mark.rutland@arm.com>
3Date: Tue, 3 Apr 2018 11:22:51 +0100
4Subject: arm64: only advance singlestep for user instruction traps
5
6From: Mark Rutland <mark.rutland@arm.com>
7
8commit 9478f1927e6ef9ef5e1ad761af1c98aa8e40b7f5 upstream.
9
10Our arm64_skip_faulting_instruction() helper advances the userspace
11singlestep state machine, but this is also called by the kernel BRK
12handler, as used for WARN*().
13
14Thus, if we happen to hit a WARN*() while the user singlestep state
15machine is in the active-no-pending state, we'll advance to the
16active-pending state without having executed a user instruction, and
17will take a step exception earlier than expected when we return to
18userspace.
19
20Let's fix this by only advancing the state machine when skipping a user
21instruction.
22
23Signed-off-by: Mark Rutland <mark.rutland@arm.com>
24Cc: Andrey Konovalov <andreyknvl@google.com>
25Cc: Catalin Marinas <catalin.marinas@arm.com>
26Cc: Will Deacon <will.deacon@arm.com>
27Signed-off-by: Will Deacon <will.deacon@arm.com>
28Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
29Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31---
32 arch/arm64/kernel/traps.c | 3 ++-
33 1 file changed, 2 insertions(+), 1 deletion(-)
34
35--- a/arch/arm64/kernel/traps.c
36+++ b/arch/arm64/kernel/traps.c
37@@ -304,7 +304,8 @@ void arm64_skip_faulting_instruction(str
38 * If we were single stepping, we want to get the step exception after
39 * we return from the trap.
40 */
41- user_fastforward_single_step(current);
42+ if (user_mode(regs))
43+ user_fastforward_single_step(current);
44 }
45
46 static LIST_HEAD(undef_hook);