From: Thomas Gleixner <tglx@kernel.org>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org,
Huacai Chen <chenhuacai@kernel.org>,
loongarch@lists.linux.dev, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-riscv@lists.infradead.org,
Sven Schnelle <svens@linux.ibm.com>,
linux-s390@vger.kernel.org, x86@kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Jinjie Ruan <ruanjinjie@huawei.com>,
Magnus Lindholm <linmag7@gmail.com>,
"Mukesh Kumar Chaurasiya (IBM)" <mkchauras@gmail.com>,
Jonathan Corbet <corbet@lwn.net>, Radu Rendec <radu@rendec.net>
Subject: Re: [patch 4/4] entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution
Date: Tue, 14 Jul 2026 00:20:49 +0200 [thread overview]
Message-ID: <871pd6r0ou.ffs@fw13> (raw)
In-Reply-To: <alSlg72c8xmjaj48@kunlun.suse.cz>
On Mon, Jul 13 2026 at 10:44, Michal Suchánek wrote:
> On Sun, Jul 12, 2026 at 11:25:32PM +0200, Thomas Gleixner wrote:
>> The return values of syscall_enter_from_user_mode[_work]() are
>> non-intuitive. Both functions return the syscall number which should be
>> invoked by the architecture specific syscall entry code. The returned
>> number can be:
>>
>> - the unmodified syscall number which was handed in by the caller
>>
>> - a modified syscall number (ptrace, seccomp, trace/probe/bpf)
>>
>> That has an additional twist. If the return value is -1L then the caller is
>> not allowed to modify the return value as that indicates that the modifying
>> entity requests to abort the syscall and set the return value already. That
>> can obviously not be differentiated from a syscall which handed in -1 as
>> syscall number.
>>
>> The most trivial way to deal with that is:
>>
>> set_return_value(regs, -ENOSYS);
>> nr = syscall_enter_from_user_mode(regs, nr);
>> if (valid(nr))
>> handle_syscall(regs, nr);
>>
>> That's what LOONGARCH, RISCV, and X86 do. But PowerPC and S390 do not
>> preset the return value, so when user space hands in -1 and there is
>> nothing setting the return value in the entry work code, then the syscall
>> is skipped but the return value is whatever random data has been in the
>> return value register.
>
> The reason why PowerPC and S390 do not preset the return value is that
> the return value uses the same register as the syscall number. There are
> apparently other architectures on which the return value overlaps with
> the arguments which also do not preset the return value for that reason.
> If they would use the generic entry the same problem would arise.
That's an implementation choice of PPC/S390 as I explained before, which
could trivially be solved by having an explicit pt_regs->return_val
member,
>> Change the return values of syscall_enter_from_user_mode[_work]() to
>> boolean and return false, when either ptrace or seccomp request to skip the
>
> There is a difference between seccomp and ptrace.
>
> When seccomp indicates to skip the syscall it has also set the syscall
> return value.
>
> However, when the syscall number is -1 and the return value is not
> preset that does not indicate anything.
I agree it's an invalid syscall, but the current generic entry code made
the rightful assumption that returning -1L as the syscall number either
results in -ENOSYS or in the value which was set by one of the entry
mechanisms as that code originated from the x86 implementation.
It's not the fault of that code that PPC and S390 converted their stuff
over without paying attention to that detail.
> The return value can still hold garbage. ptrace does not have the
> ability to indicate that a syscall is to be skipped, at least on the
> entry trace. It needs to be skipped based on the syscall number being
> invalid.
That's what I explained you before and you told me I'm all wrong.
But that's moot as this latest version does not care anymore. The
architectures whixh preset the return value are correct under all
circumstances and PPC/S390 can keep their own world view.
Thanks,
tglx
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@kernel.org>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org,
Huacai Chen <chenhuacai@kernel.org>,
loongarch@lists.linux.dev, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-riscv@lists.infradead.org,
Sven Schnelle <svens@linux.ibm.com>,
linux-s390@vger.kernel.org, x86@kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Jinjie Ruan <ruanjinjie@huawei.com>,
Magnus Lindholm <linmag7@gmail.com>,
"Mukesh Kumar Chaurasiya (IBM)" <mkchauras@gmail.com>,
Jonathan Corbet <corbet@lwn.net>, Radu Rendec <radu@rendec.net>
Subject: Re: [patch 4/4] entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution
Date: Tue, 14 Jul 2026 00:20:49 +0200 [thread overview]
Message-ID: <871pd6r0ou.ffs@fw13> (raw)
In-Reply-To: <alSlg72c8xmjaj48@kunlun.suse.cz>
On Mon, Jul 13 2026 at 10:44, Michal Suchánek wrote:
> On Sun, Jul 12, 2026 at 11:25:32PM +0200, Thomas Gleixner wrote:
>> The return values of syscall_enter_from_user_mode[_work]() are
>> non-intuitive. Both functions return the syscall number which should be
>> invoked by the architecture specific syscall entry code. The returned
>> number can be:
>>
>> - the unmodified syscall number which was handed in by the caller
>>
>> - a modified syscall number (ptrace, seccomp, trace/probe/bpf)
>>
>> That has an additional twist. If the return value is -1L then the caller is
>> not allowed to modify the return value as that indicates that the modifying
>> entity requests to abort the syscall and set the return value already. That
>> can obviously not be differentiated from a syscall which handed in -1 as
>> syscall number.
>>
>> The most trivial way to deal with that is:
>>
>> set_return_value(regs, -ENOSYS);
>> nr = syscall_enter_from_user_mode(regs, nr);
>> if (valid(nr))
>> handle_syscall(regs, nr);
>>
>> That's what LOONGARCH, RISCV, and X86 do. But PowerPC and S390 do not
>> preset the return value, so when user space hands in -1 and there is
>> nothing setting the return value in the entry work code, then the syscall
>> is skipped but the return value is whatever random data has been in the
>> return value register.
>
> The reason why PowerPC and S390 do not preset the return value is that
> the return value uses the same register as the syscall number. There are
> apparently other architectures on which the return value overlaps with
> the arguments which also do not preset the return value for that reason.
> If they would use the generic entry the same problem would arise.
That's an implementation choice of PPC/S390 as I explained before, which
could trivially be solved by having an explicit pt_regs->return_val
member,
>> Change the return values of syscall_enter_from_user_mode[_work]() to
>> boolean and return false, when either ptrace or seccomp request to skip the
>
> There is a difference between seccomp and ptrace.
>
> When seccomp indicates to skip the syscall it has also set the syscall
> return value.
>
> However, when the syscall number is -1 and the return value is not
> preset that does not indicate anything.
I agree it's an invalid syscall, but the current generic entry code made
the rightful assumption that returning -1L as the syscall number either
results in -ENOSYS or in the value which was set by one of the entry
mechanisms as that code originated from the x86 implementation.
It's not the fault of that code that PPC and S390 converted their stuff
over without paying attention to that detail.
> The return value can still hold garbage. ptrace does not have the
> ability to indicate that a syscall is to be skipped, at least on the
> entry trace. It needs to be skipped based on the syscall number being
> invalid.
That's what I explained you before and you told me I'm all wrong.
But that's moot as this latest version does not care anymore. The
architectures whixh preset the return value are correct under all
circumstances and PPC/S390 can keep their own world view.
Thanks,
tglx
next prev parent reply other threads:[~2026-07-13 22:21 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 21:25 [patch 0/4] entry: Rework syscall skip logic Thomas Gleixner
2026-07-12 21:25 ` Thomas Gleixner
2026-07-12 21:25 ` [patch 1/4] entry: Rework syscall_audit_enter() Thomas Gleixner
2026-07-12 21:25 ` Thomas Gleixner
2026-07-13 1:33 ` Jinjie Ruan
2026-07-13 1:33 ` Jinjie Ruan
2026-07-14 15:01 ` [tip: core/entry] " tip-bot2 for Thomas Gleixner
2026-07-14 15:23 ` [patch 1/4] " Radu Rendec
2026-07-14 15:23 ` Radu Rendec
2026-07-12 21:25 ` [patch 2/4] entry: Rework trace_syscall_enter() Thomas Gleixner
2026-07-12 21:25 ` Thomas Gleixner
2026-07-13 1:36 ` Jinjie Ruan
2026-07-13 1:36 ` Jinjie Ruan
2026-07-14 15:01 ` [tip: core/entry] " tip-bot2 for Thomas Gleixner
2026-07-14 15:28 ` [patch 2/4] " Radu Rendec
2026-07-14 15:28 ` Radu Rendec
2026-07-12 21:25 ` [patch 3/4] entry: Make return type of syscall_trace_enter() bool Thomas Gleixner
2026-07-12 21:25 ` Thomas Gleixner
2026-07-13 1:40 ` Jinjie Ruan
2026-07-13 1:40 ` Jinjie Ruan
2026-07-14 15:01 ` [tip: core/entry] " tip-bot2 for Thomas Gleixner
2026-07-14 15:41 ` [patch 3/4] " Radu Rendec
2026-07-14 15:41 ` Radu Rendec
2026-07-12 21:25 ` [patch 4/4] entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution Thomas Gleixner
2026-07-12 21:25 ` Thomas Gleixner
2026-07-13 8:44 ` Michal Suchánek
2026-07-13 17:00 ` Michal Suchánek
2026-07-13 17:00 ` Michal Suchánek
2026-07-13 22:20 ` Thomas Gleixner [this message]
2026-07-13 22:20 ` Thomas Gleixner
2026-07-14 7:29 ` Michal Suchánek
2026-07-14 7:29 ` Michal Suchánek
2026-07-14 8:40 ` Michal Suchánek
2026-07-14 15:01 ` [tip: core/entry] " tip-bot2 for Thomas Gleixner
2026-07-14 12:27 ` [patch 0/4] entry: Rework syscall skip logic Michal Suchánek
2026-07-14 12:27 ` Michal Suchánek
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=871pd6r0ou.ffs@fw13 \
--to=tglx@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=corbet@lwn.net \
--cc=linmag7@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=mkchauras@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=radu@rendec.net \
--cc=ruanjinjie@huawei.com \
--cc=sshegde@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=x86@kernel.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.