]> git.baikalelectronics.ru Git - kernel.git/commit
entry: Ensure trap after single-step on system call return
authorGabriel Krisman Bertazi <krisman@collabora.com>
Wed, 3 Feb 2021 18:00:48 +0000 (13:00 -0500)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 5 Feb 2021 23:21:42 +0000 (00:21 +0100)
commitc4f561a9919e6edbadf8c86390350e867aab2176
treed75d12186c1d9e79168bdd0b84740d7701bee408
parentc34d363cb9bb3d3df914b00046864c1326569017
entry: Ensure trap after single-step on system call return

Commit 8162b3a1505c ("entry: Drop usage of TIF flags in the generic syscall
code") introduced a bug on architectures using the generic syscall entry
code, in which processes stopped by PTRACE_SYSCALL do not trap on syscall
return after receiving a TIF_SINGLESTEP.

The reason is that the meaning of TIF_SINGLESTEP flag is overloaded to
cause the trap after a system call is executed, but since the above commit,
the syscall call handler only checks for the SYSCALL_WORK flags on the exit
work.

Split the meaning of TIF_SINGLESTEP such that it only means single-step
mode, and create a new type of SYSCALL_WORK to request a trap immediately
after a syscall in single-step mode.  In the current implementation, the
SYSCALL_WORK flag shadows the TIF_SINGLESTEP flag for simplicity.

Update x86 to flip this bit when a tracer enables single stepping.

Fixes: 8162b3a1505c ("entry: Drop usage of TIF flags in the generic syscall code")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Kyle Huey <me@kylehuey.com>
Link: https://lore.kernel.org/r/87h7mtc9pr.fsf_-_@collabora.com
arch/x86/include/asm/entry-common.h
arch/x86/kernel/step.c
include/linux/entry-common.h
include/linux/thread_info.h
kernel/entry/common.c