summary refs log tree commit diff
path: root/arch/x86/kernel/step.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2021-02-12 12:54:51 +0100
committerIngo Molnar <mingo@kernel.org>2021-02-12 12:54:58 +0100
commit62137364e3e8afcc745846c5c67cacf943149073 (patch)
tree42f2bdee6b16e383b6e0a94cb3abc62f335d721a /arch/x86/kernel/step.c
parent6c80408a8a0360fa9223b8c21c0ab8ef42e88bfe (diff)
parentdcc0b49040c70ad827a7f3d58a21b01fdb14e749 (diff)
downloadlinux-62137364e3e8afcc745846c5c67cacf943149073.tar.gz
Merge branch 'linus' into locking/core, to pick up upstream fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/step.c')
-rw-r--r--arch/x86/kernel/step.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
index 60d2c3798ba2..0f3c307b37b3 100644
--- a/arch/x86/kernel/step.c
+++ b/arch/x86/kernel/step.c
@@ -127,12 +127,17 @@ static int enable_single_step(struct task_struct *child)
 		regs->flags |= X86_EFLAGS_TF;
 
 	/*
-	 * Always set TIF_SINGLESTEP - this guarantees that
-	 * we single-step system calls etc..  This will also
+	 * Always set TIF_SINGLESTEP.  This will also
 	 * cause us to set TF when returning to user mode.
 	 */
 	set_tsk_thread_flag(child, TIF_SINGLESTEP);
 
+	/*
+	 * Ensure that a trap is triggered once stepping out of a system
+	 * call prior to executing any user instruction.
+	 */
+	set_task_syscall_work(child, SYSCALL_EXIT_TRAP);
+
 	oflags = regs->flags;
 
 	/* Set TF on the kernel stack.. */
@@ -230,6 +235,7 @@ void user_disable_single_step(struct task_struct *child)
 
 	/* Always clear TIF_SINGLESTEP... */
 	clear_tsk_thread_flag(child, TIF_SINGLESTEP);
+	clear_task_syscall_work(child, SYSCALL_EXIT_TRAP);
 
 	/* But touch TF only if it was set by us.. */
 	if (test_and_clear_tsk_thread_flag(child, TIF_FORCED_TF))