All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@strace.io>
To: Renzo Davoli <renzo@cs.unibo.it>
Cc: linux-kernel@vger.kernel.org,
	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
Subject: Re: [PATCH v2 1/2] ptrace: PTRACE_SET_SYSCALL_INFO syscall skipping support
Date: Mon, 6 Jul 2026 19:03:27 +0300	[thread overview]
Message-ID: <20260706160327.GB5029@strace.io> (raw)
In-Reply-To: <akn8g3ya85YFqcjV@cs.unibo.it>

On Sun, Jul 05, 2026 at 08:41:07AM +0200, Renzo Davoli wrote:
[...]
> 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.
>  */

I wrote this comment to warn explicitly against invoking
syscall_set_arguments() after syscall_set_nr(-1).  Doing so is unsafe on
several architectures, as setting the first syscall argument will clobber
the syscall return value on those platforms.

[...]
> 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.

While setting the system call number to an invalid value during a
syscall-entry stop indeed suppresses the system call on all architectures,
the return value semantics are complicated.

The return value is normally set to -ENOSYS, but there are architectures
(parisc between commits v4.6-rc2~20^2 and v5.0-rc8~9^2~1, and riscv
since commit v6.5-rc7~13^2~5) where -ENOSYS isn't set.  Furthermore,
setting the return value along with the system call number during
a syscall-entry stop is not guaranteed to be honored on all architectures,
with MIPS being a notable example.

The man page could definitely be improved in this respect.


-- 
ldv

  parent reply	other threads:[~2026-07-06 16:03 UTC|newest]

Thread overview: 11+ 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
2026-07-05 14:38     ` Oleg Nesterov
2026-07-07 14:27       ` Renzo Davoli
2026-07-07 16:04         ` Oleg Nesterov
2026-07-07 16:09           ` Thomas Bogendoerfer
2026-07-10 12:34           ` Thomas Bogendoerfer
2026-07-12 21:27             ` Oleg Nesterov
2026-07-06 16:03     ` Dmitry V. Levin [this message]
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=20260706160327.GB5029@strace.io \
    --to=ldv@strace.io \
    --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=renzo@cs.unibo.it \
    --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 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.