The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/5] ptrace_set_syscall_info: add support for seccomp syscall skipping and instruction pointer modification
@ 2026-07-01 15:05 Renzo Davoli
  2026-07-01 15:05 ` [PATCH 1/5] ptrace: add PTRACE_SYSCALL_INFO_SECCOMP_SKIP Renzo Davoli
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Renzo Davoli @ 2026-07-01 15:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Renzo Davoli, Andrew Morton, Oleg Nesterov, Shuah Khan,
	Alexey Gladkov, Eugene Syromyatnikov, Mike Frysinger,
	Davide Berardi, strace-devel

PTRACE_SET_SYSCALL_INFO is a generic ptrace API that complements
PTRACE_GET_SYSCALL_INFO by allowing a tracer to modify details of a
system call in which the tracee is currently blocked.

The API is designed to let tracers inspect and modify system call
information in a simple, architecture-agnostic manner.

The current implementation only supports modifying the subset of
system call information needed by strace: the system call number,
arguments, and return value.

This patch set extends PTRACE_SET_SYSCALL_INFO with support for:

    Skipping a system call triggered via seccomp

    Modifying the tracee's instruction pointer

1. Seccomp system call skip

When a seccomp filter returns SECCOMP_RET_TRACE, the tracer receives,
via PTRACE_GET_SYSCALL_INFO, a struct ptrace_syscall_info with
op == PTRACE_SYSCALL_INFO_SECCOMP.

The tracer can skip the system call by setting the system call number
to -1. However, the current PTRACE_SET_SYSCALL_INFO interface does not
provide a way to specify the return value or error code that should be
reported to the tracee after skipping the call.

Patch 1/5 introduces a new op value,
PTRACE_SYSCALL_INFO_SECCOMP_SKIP, for use with
PTRACE_SET_SYSCALL_INFO.

When the tracer retrieves a ptrace_syscall_info structure with
op == PTRACE_SYSCALL_INFO_SECCOMP, it may choose to skip the system
call by changing op to PTRACE_SYSCALL_INFO_SECCOMP_SKIP and
populating the exit union fields (rval and is_error) to define
the return value and error status for the tracee.

2. Setting the instruction pointer

Patch 4/5 adds support for modifying the tracee's instruction pointer.

To do this, the tracer stores the new instruction pointer value in the
instruction_pointer field of the ptrace_syscall_info structure and
sets the PTRACE_SYSCALL_INFO_FLAG_SET_IP flag in the flags field.

This flag is introduced to avoid breaking existing code that uses
PTRACE_SET_SYSCALL_INFO and currently ignores the
instruction_pointer field.

Renzo Davoli (5):
  ptrace: add PTRACE_SYSCALL_INFO_SECCOMP_SKIP
  selftests/ptrace: add a test case for PTRACE_SYSCALL_INFO_SECCOMP_SKIP
  asm/ptrace.h: add instruction_pointer_set
  ptrace: add PTRACE_SYSCALL_INFO_FLAG_SET_IP
  selftests/ptrace: add a test case for PTRACE_SYSCALL_INFO_FLAG_SET_IP

 arch/alpha/include/asm/ptrace.h               |   6 +
 arch/hexagon/include/asm/ptrace.h             |   6 +
 arch/m68k/include/asm/ptrace.h                |   6 +
 arch/microblaze/include/asm/ptrace.h          |   6 +
 arch/nios2/include/asm/ptrace.h               |   6 +
 arch/um/include/asm/ptrace-generic.h          |   6 +
 arch/xtensa/include/asm/ptrace.h              |   6 +
 include/uapi/linux/ptrace.h                   |   5 +
 kernel/ptrace.c                               |  39 ++-
 .../selftests/ptrace/set_syscall_info.c       | 321 +++++++++++++++++-
 10 files changed, 401 insertions(+), 6 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-07-02 16:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 15:05 [PATCH 0/5] ptrace_set_syscall_info: add support for seccomp syscall skipping and instruction pointer modification Renzo Davoli
2026-07-01 15:05 ` [PATCH 1/5] ptrace: add PTRACE_SYSCALL_INFO_SECCOMP_SKIP Renzo Davoli
2026-07-02  8:43   ` Oleg Nesterov
2026-07-02  9:09     ` Renzo Davoli
2026-07-02  9:58       ` Oleg Nesterov
2026-07-02 11:07         ` Dmitry V. Levin
2026-07-02 11:31           ` Oleg Nesterov
2026-07-02 11:39             ` Oleg Nesterov
2026-07-02 14:47               ` Oleg Nesterov
2026-07-02 16:10                 ` Renzo Davoli
2026-07-01 15:05 ` [PATCH 2/5] selftests/ptrace: add a test case for PTRACE_SYSCALL_INFO_SECCOMP_SKIP Renzo Davoli
2026-07-01 15:05 ` [PATCH 3/5] asm/ptrace.h: add instruction_pointer_set Renzo Davoli
2026-07-01 15:05 ` [PATCH 4/5] ptrace: add PTRACE_SYSCALL_INFO_FLAG_SET_IP Renzo Davoli
2026-07-01 15:05 ` [PATCH 5/5] selftests/ptrace: add a test case for PTRACE_SYSCALL_INFO_FLAG_SET_IP Renzo Davoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox