[PATCH] selftests/ptrace: Add PTRACE_SYSEMU_SINGLESTEP syscall-exit-stop test
Oleg Nesterov
oleg at redhat.com
Wed Sep 23 04:07:09 PDT 2026
On 09/22, Kees Cook wrote:
>
> ptrace(2) states that no syscall-exit-stop occurs when a tracee is
> continued with PTRACE_SYSEMU or PTRACE_SYSEMU_SINGLESTEP. arm64 gated
> its syscall-exit report on
>
> flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)
>
> and ptrace_resume() clears SYSCALL_TRACE for both SYSEMU requests while
> PTRACE_SYSEMU_SINGLESTEP additionally sets TIF_SINGLESTEP, so the
> single-step bit alone produced a stop that must not exist. Nothing in
> tools/testing/selftests covered this.
IOW, this test-case veirifies that in the sequence like the generic code
step = report_single_step(work);
if (step || work & SYSCALL_WORK_SYSCALL_TRACE)
arch_ptrace_report_syscall_exit(regs, step);
report_single_step() returns false, right? SYSCALL_TRACE is cleared by
the arch neutral code...
> Link: https://lore.kernel.org/all/20260922035510.1090299-2-ruanjinjie@huawei.com/ [1]
> Assisted-by: LLM
> Signed-off-by: Kees Cook <kees at kernel.org>
> ---
> tools/testing/selftests/ptrace/Makefile | 3 +-
> .../selftests/ptrace/sysemu_singlestep.c | 176 ++++++++++++++++++
> tools/testing/selftests/ptrace/.gitignore | 1 +
> 3 files changed, 179 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/ptrace/sysemu_singlestep.c
Reviewed-by: Oleg Nesterov <oleg at redhat.com>
More information about the linux-arm-kernel
mailing list