From: Renzo Davoli <renzo@cs.unibo.it>
To: linux-kernel@vger.kernel.org
Cc: 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>,
Davide Berardi <berardi.dav@gmail.com>,
strace-devel@lists.strace.io, "Dmitry V . Levin" <ldv@strace.io>
Subject: Re: [PATCH v2 1/2] ptrace: PTRACE_SET_SYSCALL_INFO syscall skipping support
Date: Sun, 5 Jul 2026 08:41:07 +0200 [thread overview]
Message-ID: <akn8g3ya85YFqcjV@cs.unibo.it> (raw)
In-Reply-To: <20260704142643.692754-2-renzo@cs.unibo.it>
There is a problem on MIPS:
https://sashiko.dev/#/patchset/20260704142643.692754-1-renzo%40cs.unibo.it
It appears that on MIPS the feature of skipping a system call by setting its
number to -1 does not work correctly when transitioning from _ENTRY to _EXIT:
the system call return value is overwritten.
PTRACE_EVENT_SECCOMP, however, has an explicit UAPI specification stating that
setting the system call number to a negative value suppresses the system call.
Moreover, kernel/ptrace.c contains the following comment:
/*
* If the syscall number is set to -1, setting syscall arguments is not
* just pointless, it would also clobber the syscall return value on
* those architectures that share the same register both for the first
* argument of syscall and its return value.
*/
Thus, PTRACE_EVENT_SECCOMP is explicitly designed to preserve the system call
return value when the system call is skipped.
By contrast, for PTRACE_SYSCALL syscall-entry stops, the man page only states
that the tracer may modify the system call number. It does not specify that
assigning a negative value must suppress the system call and preserve the
return value across all architectures, even though many architectures implement
exactly this behavior.
At this point I see two possible approaches:
* fix the MIPS implementation (and audit, and possibly fix, the other
architectures as well);
* revert to the original proposal and allow the "skip syscall" feature only for
PTRACE_EVENT_SECCOMP, i.e. permit PTRACE_SET_SYSCALL_INFO to transform only
PTRACE_SYSCALL_INFO_SECCOMP stops into PTRACE_SYSCALL_INFO_EXIT stops.
I would prefer the latter approach. I am concerned that changing the ptrace
implementation in each architecture may introduce subtle regressions or other
unintended side effects.
In my opinion, seccomp-based syscall tracing is also the more powerful and
flexible model compared to the traditional PTRACE_SYSCALL entry/exit mechanism.
Support for system call suppression from PTRACE_SYSCALL_INFO_ENTRY can always
be added later if and when a real use case arises. That would also provide an
opportunity to audit the behavior of all supported architectures and, if
necessary, make the semantics of negative system call numbers consistent across
architectures.
renzo
next prev parent reply other threads:[~2026-07-05 6:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 14:26 [PATCH v2 0/2] ptrace_set_syscall_info: add support for seccomp syscall skipping Renzo Davoli
2026-07-04 14:26 ` [PATCH v2 1/2] ptrace: PTRACE_SET_SYSCALL_INFO syscall skipping support Renzo Davoli
2026-07-05 6:41 ` Renzo Davoli [this message]
2026-07-05 14:38 ` Oleg Nesterov
2026-07-06 16:03 ` Dmitry V. Levin
2026-07-04 14:26 ` [PATCH v2 2/2] selftests/ptrace: add a test case for PTRACE_SYSCALL_INFO syscall skipping 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=akn8g3ya85YFqcjV@cs.unibo.it \
--to=renzo@cs.unibo.it \
--cc=akpm@linux-foundation.org \
--cc=berardi.dav@gmail.com \
--cc=evgsyr@gmail.com \
--cc=ldv@strace.io \
--cc=legion@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=shuah@kernel.org \
--cc=strace-devel@lists.strace.io \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox