[PATCH v2 0/5] ptrace_set_syscall_info: add support for seccomp syscall skipping and instruction pointer modification

From: Renzo Davoli

Date: Fri Jul 03 2026 - 07:01:32 EST


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 adds a new feature to solve the problem.

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_EXIT 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.

Changes in v2:
* use PTRACE_SYSCALL_INFO_EXIT instead of a new tag
* fixed most the comments from sashiko.dev

Renzo Davoli (5):
ptrace: PTRACE_SET_SYSCALL_INFO syscall skipping support
selftests/ptrace: add a test case for PTRACE_SYSCALL_INFO syscall
skipping
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 | 4 +
kernel/ptrace.c | 46 ++-
.../selftests/ptrace/set_syscall_info.c | 327 +++++++++++++++++-
10 files changed, 409 insertions(+), 10 deletions(-)

--
2.53.0