Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=130.136.161.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792479428; b=AkWCV4Qg4fZF7nyZxY6RVMyPjSdGVKz7n04qoVNdnWLM7rTxDa/KurqlZYSSq0NLhcmZ 1yQA8TI5sYyROPsg/aHr9Ux7rqRb4RAKwEHkhWo7b0zKB/I5jPr1BdWzknDDz3erUsrS5 xnOhAGa/tUPZRgK8AktHbAsnZ6NGXCe91irQFxII+UpCKWh7qPgqxBryo5sQHT9utexrz IC62bdRCmRIZonJPLMDkPqFU0L5rlPjJW1qO007Q9M1B6YsgsJXFr1ZP9MPDYxR051axo UVF5Z6rzsL6L3/9GAhw5OFw9b6zU18m/oUl3k+Etsl3PoBMvy0XqPRYyzaMp5y9BgXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792479428; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=AtfaIB7zNIcokdWhAV1B+vumdcEZUgvLFCxAn12t790=; b=vrfabtIkbEFFiW1ClaVICm6iAtml1crHi7JPgjFidUcmEhnDUyCqn4GQ89T/dGNVrKfB FIN1FksvBZZINjMx5gPaApZaB6ntcTpVUR9TqovJj/zD9Qoo7dG3tgvomnw69wNKD32G8 n9lA1Vn/7BqS3O1DmlmhdQa8ZLvdykFrJ31Y5nM+bQJ9ZbvnDzkaHifCyeD6PIpQ1VoDQ xf94CRXNIeIeQqhBEUJrYaovrAZp4SBX7q2CSPY5exUoxt3mOeTNul0kEJ8KGQcR2YXyt KIn8wXI6RkPHfngDxnz00Ti5AhV64C/AKjxpnTprJZkZ4KMGqwN+0gd752nj0kCsfeQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cs.unibo.it; spf=pass smtp.mailfrom=cs.unibo.it; dkim=pass header.d=cs.unibo.it header.i=@cs.unibo.it header.a=rsa-sha256 header.s=virtlab header.b="wM/PVUNn"; arc=none smtp.remote-ip=130.136.161.50 Received: from mail.virtlab.unibo.it (mail.virtlab.unibo.it [130.136.161.50]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92630606A31E; Tue, 20 Oct 2026 06:57:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 92630606A31E 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, unprotected) header.d=cs.unibo.it header.i=@cs.unibo.it header.a=rsa-sha256 header.s=virtlab header.b=wM/PVUNn Received: from eipi10.cs.unibo.it (unknown [94.32.99.206]) by mail.virtlab.unibo.it (Postfix) with ESMTPA id 6E42A1C007A; Tue, 20 Oct 2026 08:56:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cs.unibo.it; s=virtlab; t=1792479417; bh=8k+f6s1iBSMA7KdqSLVFKJqY4O8BHwfAeNveqUnEYQE=; h=From:To:Cc:Subject:Date:From; b=wM/PVUNnw86yViL3yGqD3Wom6NcR7xLNm22vqyRI5BuZO32PHsW6+A5Ho9ukhXc2p 9tsx3NP1nCI7ieT2KLMb/Lomk7e3TZKm7CxFv4TKkGFpHu39vJJ3ErYcuEc6N10kz0 k5lRM3oHIVQQK6569O30JiEAjgpmXJWOzAb8pdyc= From: Renzo Davoli To: linux-kernel@vger.kernel.org Cc: Renzo Davoli , Oleg Nesterov , =?UTF-8?q?Michal=20Such=C3=A1nek?= , Kees Cook , Andy Lutomirski , Will Drewry , Thomas Gleixner , Andrew Morton , Shuah Khan , "Dmitry V . Levin" , Alexey Gladkov , Eugene Syromyatnikov , Davide Berardi , Thomas Bogendoerfer , Heiko Carstens , Vasily Gorbik , Madhavan Srinivasan , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org, strace-devel@lists.strace.io Subject: [PATCH v8 0/3] PTRACE_SET_SYSCALL_INFO: add support for seccomp syscall skipping Date: Tue, 20 Oct 2026 08:56:30 +0200 Message-ID: <20261020065635.490528-1-renzo@cs.unibo.it> X-Mailer: git-send-email 2.55.0 X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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. This patch set extends PTRACE_SET_SYSCALL_INFO with support for skipping a system call at a PTRACE_EVENT_SECCOMP stop and setting its return value. To do this, the tracer changes 'op' from PTRACE_SYSCALL_INFO_SECCOMP to PTRACE_SYSCALL_INFO_EXIT and fills in the exit union fields (rval and is_error). Michal pointed out in the review of v7 [1] that the register state alone cannot tell whether a syscall has to be executed or skipped with a preset return value, since on some architectures the return value shares a register with the syscall number or the arguments, and that the "already dispatched" information should be architecture independent rather than an architecture-specific thread flag. v8 does exactly that: the tracer no longer sets the syscall number to -1 and relies on syscall_get_nr() reading it back as negative. Instead, patch 1 adds a per-task flag owned by seccomp, which the tracer sets while the tracee is stopped. When the tracee resumes, seccomp skips the system call just like for SECCOMP_RET_ERRNO, a path every architecture already handles without touching the return value. This also fixes skipping on s390, where -1 is read back as syscall 65535. On powerpc, this series depends on the fix posted separately [2]: syscall_set_return_value() currently sets TIF_SYSCALL_RET on the *caller*, i.e. on the tracer when called from PTRACE_SET_SYSCALL_INFO, and skipped system calls lose non-error return values. Both problems are regressions in v7.3-rc and already break the existing set_syscall_info selftest and seccomp_bpf user_notification_basic on ppc64le. [1] https://lore.kernel.org/lkml/apWFHkZnCMfxQCEk@kunlun.suse.cz/ [2] https://lore.kernel.org/lkml/20261018151539.440213-1-renzo@cs.unibo.it/ Testing (QEMU, v7.3-rc6, tools/testing/selftests/ptrace/set_syscall_info and tools/testing/selftests/seccomp/seccomp_bpf): x86_64 (KVM) ppc64le (TCG) s390x (TCG) ptrace/set_syscall_info 2/2 2/2 2/2 seccomp/seccomp_bpf 111/111 111/111 110/111 (*) Skipping getpid() at a PTRACE_EVENT_SECCOMP stop, with a filter that kills the process on unknown syscall numbers: op=SECCOMP, nr=-1 (before) error r3 left as is SIGSYS kill op=SECCOMP->EXIT (this) -ESRCH -ESRCH -ESRCH (*) user_notification_wait_killable_after_reply timed out under TCG while another VM was running; it passes 5/5 both with and without this series on an idle x86_64 KVM guest. Build-tested also with CONFIG_SECCOMP=n and CONFIG_SECCOMP_FILTER=n. Not tested: MIPS, arm64, riscv, loongarch, real hardware. Changes in v8: * skip the system call via a seccomp per-task flag instead of syscall_set_nr(-1), as suggested by Michal Suchánek * new helper ptrace_set_syscall_info_seccomp_skip() instead of a bool argument to ptrace_set_syscall_info_exit() (Michal Suchánek) * once the system call is skipped, reject further PTRACE_SYSCALL_INFO_SECCOMP updates during the same stop * selftest: also test an error return value and the above * dropped the Reviewed-by tags of Oleg and Dmitry, as patch 2 changed significantly Changes in v7: * rebased to Linux 7.3-rc1 Changes in v6: * selftests/ptrace/set_syscall_info.c: improve messages in case of failure. Changes in v5: * reworded the explanation for not supporting PTRACE_SYSCALL_INFO_ENTRY yet. * selftests/ptrace: removed a redundant check. 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 Davide Berardi (1): seccomp: let the tracer skip a syscall independently of its number 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 include/linux/seccomp.h | 33 +++ include/linux/seccomp_types.h | 4 + kernel/ptrace.c | 45 +++- kernel/seccomp.c | 11 +- .../selftests/ptrace/set_syscall_info.c | 220 +++++++++++++++++- 5 files changed, 309 insertions(+), 4 deletions(-) base-commit: 32c52ec87d6245ee2d12ed5dd509e40062939b50 prerequisite-patch-id: abdd0fc0973bc3845ae7bfe84d855a7213ccd3d7 -- 2.55.0