mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michal Suchánek" <msuchanek@suse.de>
To: Renzo Davoli <renzo@cs.unibo.it>
Cc: linux-kernel@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
	Kees Cook <kees@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>, Thomas Gleixner <tglx@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>, "Dmitry V . Levin" <ldv@strace.io>,
	Alexey Gladkov <legion@kernel.org>,
	Eugene Syromyatnikov <evgsyr@gmail.com>,
	Davide Berardi <berardi.dav@gmail.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
	linux-kselftest@vger.kernel.org, strace-devel@lists.strace.io
Subject: Re: [PATCH v11 0/3] PTRACE_SET_SYSCALL_INFO: add support for seccomp syscall skipping
Date: Wed, 18 Nov 2026 12:42:32 +0100	[thread overview]
Message-ID: <av2PKIf8YsEPro8O@kunlun.suse.cz> (raw)
In-Reply-To: <20261114181923.370930-1-renzo@cs.unibo.it>

On Sat, Nov 14, 2026 at 07:19:19PM +0100, Renzo Davoli wrote:
> 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).

Hello,

from a user point of view it is not clear to me why this would be done
at the seccomp event when seccomp is not used.

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

On s390 the removal of such architecture-specific flag is proposed here:

https://lore.kernel.org/linux-s390/890e50e0-77f7-43f3-b1b9-f8e7302aa3db-agordeev@linux.ibm.com/T/#m04254224bb28b747314346153629207c5acca6f9

While that shows a way to address this problem not all affected
architectures implement it.

Thanks

Michal

> 
> 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, a separate fix has been posted [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.  These problems
> are already present in the source tree and break the existing
> set_syscall_info selftest and seccomp_bpf user_notification_basic on
> ppc64le independently of this series, which therefore no longer
> depends on [2].
> 
> [1] https://lore.kernel.org/lkml/apWFHkZnCMfxQCEk@kunlun.suse.cz/
> [2] https://lore.kernel.org/lkml/20261030084926.1068384-1-renzo@cs.unibo.it/
> [3] https://sashiko.dev/#/patchset/20261113165509.229869-1-renzo@cs.unibo.it?part=2
> 
> Testing (tools/testing/selftests/ptrace/set_syscall_info and
> tools/testing/selftests/seccomp/seccomp_bpf):
> 
> v11, QEMU, v7.4-rc2:
> 
>                                x86_64 (KVM)
>   ptrace/set_syscall_info      2/2
>   seccomp/seccomp_bpf          142/142
> 
> v9, QEMU, v7.3-rc6 (the v11 change is architecture independent):
> 
>                                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 (*)
> 
>   Build-tested also with CONFIG_SECCOMP=n and CONFIG_SECCOMP_FILTER=n.
> 
>   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.
> 
>   ppc64le results were obtained with an earlier version of the powerpc
>   fix [2] applied.
> 
>   Not tested: MIPS, arm64, riscv, loongarch, real hardware.
> 
> Changes in v11:
> * once the system call is skipped, PTRACE_GET_SYSCALL_INFO reports the
>   stop as a PTRACE_SYSCALL_INFO_EXIT one, as the syscall number and
>   arguments may have been overwritten by the return value (reported by
>   Sashiko [3]); a later PTRACE_SYSCALL_INFO_SECCOMP update is still
>   rejected, now by the generic check on the stop type
> * selftests/ptrace/set_syscall_info.c: check PTRACE_GET_SYSCALL_INFO
>   after the system call is skipped
> 
> Changes in v10:
> * rebased to Linux 7.4-rc2
> * no longer depends on the powerpc fix [2], which addresses a bug
>   already present in the source tree
> 
> Changes in v9:
> * selftests/ptrace/set_syscall_info.c: check for seccomp filter support,
>   fix failure report
> * rebased to Linux 7.3
> 
> 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                               |  49 +++-
>  kernel/seccomp.c                              |  11 +-
>  .../selftests/ptrace/set_syscall_info.c       | 249 +++++++++++++++++-
>  5 files changed, 342 insertions(+), 4 deletions(-)
> 
> base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
> -- 
> 2.55.0
> 

      parent reply	other threads:[~2026-11-18 11:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 18:19 Renzo Davoli
2026-11-14 18:19 ` [PATCH v11 1/3] seccomp: let the tracer skip a syscall independently of its number Renzo Davoli
2026-11-17 16:54   ` Oleg Nesterov
2026-11-14 18:19 ` [PATCH v11 2/3] ptrace: add PTRACE_SET_SYSCALL_INFO syscall skipping support Renzo Davoli
2026-11-17 16:23   ` Oleg Nesterov
2026-11-14 18:19 ` [PATCH v11 3/3] selftests/ptrace: add a test case for PTRACE_SET_SYSCALL_INFO syscall skipping Renzo Davoli
2026-11-18 11:42 ` Michal Suchánek [this message]

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=av2PKIf8YsEPro8O@kunlun.suse.cz \
    --to=msuchanek@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=berardi.dav@gmail.com \
    --cc=evgsyr@gmail.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kees@kernel.org \
    --cc=ldv@strace.io \
    --cc=legion@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=luto@amacapital.net \
    --cc=maddy@linux.ibm.com \
    --cc=oleg@redhat.com \
    --cc=renzo@cs.unibo.it \
    --cc=shuah@kernel.org \
    --cc=strace-devel@lists.strace.io \
    --cc=tglx@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=wad@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®