From: Renzo Davoli <renzo@cs.unibo.it>
To: linux-kernel@vger.kernel.org
Cc: Renzo Davoli <renzo@cs.unibo.it>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>, Shuah Khan <shuah@kernel.org>,
Alexey Gladkov <legion@kernel.org>,
Eugene Syromyatnikov <evgsyr@gmail.com>,
Mike Frysinger <vapier@gentoo.org>,
Davide Berardi <berardi.dav@gmail.com>,
strace-devel@lists.strace.io
Subject: [PATCH 1/5] ptrace: add PTRACE_SYSCALL_INFO_SECCOMP_SKIP
Date: Wed, 1 Jul 2026 17:05:54 +0200 [thread overview]
Message-ID: <20260701150558.330348-2-renzo@cs.unibo.it> (raw)
In-Reply-To: <20260701150558.330348-1-renzo@cs.unibo.it>
This patch extends PTRACE_SET_SYSCALL_INFO with support for skipping a system
call triggered via seccomp.
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.
Signed-off-by: Renzo Davoli <renzo@cs.unibo.it>
---
include/uapi/linux/ptrace.h | 1 +
kernel/ptrace.c | 28 +++++++++++++++++++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h
index 5f8ef6156752..22489597a325 100644
--- a/include/uapi/linux/ptrace.h
+++ b/include/uapi/linux/ptrace.h
@@ -79,6 +79,7 @@ struct seccomp_metadata {
#define PTRACE_SYSCALL_INFO_ENTRY 1
#define PTRACE_SYSCALL_INFO_EXIT 2
#define PTRACE_SYSCALL_INFO_SECCOMP 3
+#define PTRACE_SYSCALL_INFO_SECCOMP_SKIP 4
struct ptrace_syscall_info {
__u8 op; /* PTRACE_SYSCALL_INFO_* */
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d041645d9d17..ff763c87e4f7 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1119,12 +1119,22 @@ ptrace_set_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
return 0;
}
+static int
+ptrace_set_syscall_info_seccomp_skip(struct task_struct *child,
+ struct pt_regs *regs,
+ struct ptrace_syscall_info *info)
+{
+ syscall_set_nr(child, regs, -1);
+ return ptrace_set_syscall_info_exit(child, regs, info);
+}
+
static int
ptrace_set_syscall_info(struct task_struct *child, unsigned long user_size,
const void __user *datavp)
{
struct pt_regs *regs = task_pt_regs(child);
struct ptrace_syscall_info info;
+ int child_op;
if (user_size < sizeof(info))
return -EINVAL;
@@ -1141,9 +1151,19 @@ ptrace_set_syscall_info(struct task_struct *child, unsigned long user_size,
if (info.flags || info.reserved)
return -EINVAL;
- /* Changing the type of the system call stop is not supported yet. */
- if (ptrace_get_syscall_info_op(child) != info.op)
- return -EINVAL;
+ /*
+ * Changing the type of the system call stop is
+ * not allowed, with the following exception:
+ * PTRACE_SYSCALL_INFO_SECCOMP can be changed to
+ * PTRACE_SYSCALL_INFO_SECCOMP_SKIP.
+ */
+
+ child_op = ptrace_get_syscall_info_op(child);
+ if (child_op != info.op) {
+ if ((info.op != PTRACE_SYSCALL_INFO_SECCOMP_SKIP) ||
+ (child_op != PTRACE_SYSCALL_INFO_SECCOMP))
+ return -EINVAL;
+ }
switch (info.op) {
case PTRACE_SYSCALL_INFO_ENTRY:
@@ -1152,6 +1172,8 @@ ptrace_set_syscall_info(struct task_struct *child, unsigned long user_size,
return ptrace_set_syscall_info_exit(child, regs, &info);
case PTRACE_SYSCALL_INFO_SECCOMP:
return ptrace_set_syscall_info_seccomp(child, regs, &info);
+ case PTRACE_SYSCALL_INFO_SECCOMP_SKIP:
+ return ptrace_set_syscall_info_seccomp_skip(child, regs, &info);
default:
/* Other types of system call stops are not supported yet. */
return -EINVAL;
--
2.53.0
next prev parent reply other threads:[~2026-07-01 15:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Renzo Davoli [this message]
2026-07-02 8:43 ` [PATCH 1/5] ptrace: add PTRACE_SYSCALL_INFO_SECCOMP_SKIP 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-03 9:58 ` Oleg Nesterov
2026-07-06 14:16 ` Dmitry V. Levin
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701150558.330348-2-renzo@cs.unibo.it \
--to=renzo@cs.unibo.it \
--cc=akpm@linux-foundation.org \
--cc=berardi.dav@gmail.com \
--cc=evgsyr@gmail.com \
--cc=legion@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=shuah@kernel.org \
--cc=strace-devel@lists.strace.io \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.