Received: from mail.virtlab.unibo.it (mail.virtlab.unibo.it [130.136.161.50]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 748963E63B7 for ; Wed, 8 Jul 2026 09:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.136.161.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783501632; cv=none; b=qym0kJKyuTLQyv/tjr6S+ob4FUXdS7Tb5eFwPxqL8Lh9mY1tQsjPBnTMCS7EEKtOuLDILPdgijykNJFuh7PUCx98eShmVc1do8CbtguITi9Qgk0qhdzk8AyoOtSEklr3bGmiA9TocUtm7tBLWn2FITwZvG+ua1Vc1sBJBIGbJJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783501632; c=relaxed/simple; bh=qM0IZC99R3hiwnvEAG7leNh4+rvgAU28hQl/3J1M1ug=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a2ss2ab3wsyOP7REbWmkeDLO9idtCkOfSJ+Wt5c3Ag2XI/cbuoVAqTybAvqriOWgeE2KNQQpWwQ8wRiXq+BjiPsWUzIXgyP0Dsa68YUIaA5V/i6VhtGY7CUQviBtJe6GQQ4ZGB7VOGeqFQsJ7TRgImYpw1rFQq7ixQzyYq6ck4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cs.unibo.it; spf=pass smtp.mailfrom=cs.unibo.it; dkim=pass (1024-bit key) header.d=cs.unibo.it header.i=@cs.unibo.it header.b=rjVGGBDx; arc=none smtp.client-ip=130.136.161.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cs.unibo.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cs.unibo.it Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cs.unibo.it header.i=@cs.unibo.it header.b="rjVGGBDx" Received: from eipi10.cs.unibo.it (unknown [130.136.31.1]) by mail.virtlab.unibo.it (Postfix) with ESMTPA id D27021C0143; Wed, 8 Jul 2026 11:07:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cs.unibo.it; s=virtlab; t=1783501626; bh=qM0IZC99R3hiwnvEAG7leNh4+rvgAU28hQl/3J1M1ug=; h=From:To:Cc:Subject:Date:From; b=rjVGGBDx902rrtI/e6vF9rIwXC6FKkvQBaczSLWMR+VWytlsy2zS61SwvftzqQ25O irNUt6iVUrmBBiW85MbgDPjR+e/Ld5aSfHFnIUSEB+ljvGIuX92ggf6T2PE4+Dfl1Q HRz/iaMtWWs02hjw+/jcWPXFPAuCCnGgB2ziGtTc= From: Renzo Davoli To: linux-kernel@vger.kernel.org Cc: Renzo Davoli , Andrew Morton , Oleg Nesterov , Shuah Khan , Alexey Gladkov , Eugene Syromyatnikov , Mike Frysinger , Davide Berardi , strace-devel@lists.strace.io, "Dmitry V . Levin" Subject: [PATCH v4 0/2] PTRACE_SET_SYSCALL_INFO: add support for seccomp syscall skipping Date: Wed, 8 Jul 2026 11:06:53 +0200 Message-ID: <20260708090655.38432-1-renzo@cs.unibo.it> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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. This patchset extends PTRACE_SET_SYSCALL_INFO to support skipping a system call triggered via seccomp. When a tracer retrieves a ptrace_syscall_info structure with 'op' set to PTRACE_SYSCALL_INFO_SECCOMP, it can now choose to skip the system call. To do this, the tracer changes 'op' to PTRACE_SYSCALL_INFO_EXIT and populates the exit union fields (rval and is_error) to define the return value and error status for the tracee. System call suppression for PTRACE_SYSCALL_INFO_ENTRY is currently omitted because its implementation is architecture-dependent. On some architectures, the system call number and return value share the same register, making it difficult to suppress a system call without altering the return value. A portable implementation would require an audit of all supported architectures. This patchset is a new version of the proposed patchset entitled: ptrace_set_syscall_info: add support for seccomp syscall skipping and instruction pointer modification The patchset has been split in two: syscall skipping(this) instruction pointer modification (it will be updated soon) Changes in v4: * Reworded the commit messages for clarity. * Renamed the local variable child_op to op in ptrace_set_syscall_info() * Clean up and improve the coding style of selftests/ptrace/set_syscall_info.c (suggested by Dmitry V. Levin) Changes in v3: * restrict the syscall skipping feature to PTRACE_SYSCALL_INFO_SECCOMP Changes in v2: bugfix: _NONE -> _EXIT transition was erroneously permitted Changes since the previous patchset v2: * bugfix: skip_syscall init value * fix comments Changes in (previous patchset) v2: * use PTRACE_SYSCALL_INFO_EXIT instead of a new tag * fixed most of the comments from sashiko.dev Renzo Davoli (2): ptrace: add PTRACE_SET_SYSCALL_INFO syscall skipping support selftests/ptrace: add a test case for PTRACE_SET_SYSCALL_INFO syscall skipping kernel/ptrace.c | 27 ++- .../selftests/ptrace/set_syscall_info.c | 175 +++++++++++++++++- 2 files changed, 196 insertions(+), 6 deletions(-) -- 2.53.0