From: Thomas Gleixner <tglx@kernel.org>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, Kees Cook <kees@kernel.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>,
Andy Lutomirski <luto@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Russell King <linux@armlinux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Guo Ren <guoren@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Helge Deller <deller@gmx.de>,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Richard Weinberger <richard@nod.at>,
Chris Zankel <chris@zankel.net>,
linux-arm-kernel@lists.infradead.org,
linux-alpha@vger.kernel.org, linux-csky@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org,
linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org,
linux-um@lists.infradead.org, Arnd Bergmann <arnd@arndb.de>,
Vineet Gupta <vgupta@kernel.org>, Will Deacon <will@kernel.org>,
Brian Cain <bcain@kernel.org>, Michal Simek <monstr@monstr.eu>,
Dinh Nguyen <dinguyen@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>,
linux-snps-arc@lists.infradead.org,
linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org,
sparclinux@vger.kernel.org, linux-arch@vger.kernel.org,
Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org
Subject: Re: [patch 13/18] entry: Make trace_syscall_enter() return type bool
Date: Wed, 08 Jul 2026 22:34:38 +0200 [thread overview]
Message-ID: <87se5tqkyp.ffs@fw13> (raw)
In-Reply-To: <ak5ySpil83TNWxeq@kunlun.suse.cz>
On Wed, Jul 08 2026 at 17:52, Michal Suchánek wrote:
> On Tue, Jul 07, 2026 at 09:06:48PM +0200, Thomas Gleixner wrote:
>> In preparation of converting the return value of
>> syscall_enter_from_user_mode[_work]() bool, rework trace_syscall_enter() to
>>
>> - update the syscall number via a pointer argument
>>
>> - Return True if the syscall number is != -1, False otherwise
>
> This does not achieve the goal of the initial RFC: To detangle the
> return value of syscall_enter_from_user_mode from the syscall number.
As I explained to you before: Your RFC broke the implicit assumption of
tracing, which is way worse than having this oddity.
> This still conflates them, making it impossible to tell if the syscall
> was rejected or syscall number was -1 to start with. Now also obfuscated
> by performing the check deeper inside the common code.
That's where it belongs. It's a problem to solve within the given
semantics of trace_syscall_enter() and not a problem to be worked around
at the call sites if you want to have consolidated semantics.
>> The only difference is that this also returns False, when the syscall
>> number was already -1 to begin with, but there is not much which can be
>> done about that. As the architecture has to preset the return value to
>> -ENOSYS anyway, that results in the correct return value for such an
>> invalid syscall.
>
> That's not possible to do for architectures where the syscall number and
> the syscall return value are in the same register.
>
> You suggested that it is possible to not write the return value into an
> actual register but use an additional field for that, and have the exit
> code write the register.
>
> However, that's not what is documented, nor what is currently done.
Just because S390 screwed up their ABI and then on top of that failed to
do what _every_ other architecture in the kernel does, i.e. having a
result storage which is preset to -ENOSYS does not mean that S390 did
the right thing just because it was not documented. Kernel documentation
is known to be incomplete and I fixed it up in the last patch as you
might have noticed.
Just for the record. Presetting the return value to -ENOSYS has been
practice for three decades. I couldn't be bothered to do a full search
in the history trees to figure out the exact point, but as of 2.1.9,
which was released in Nov. 1996, this is definitely the case.
So don't tell me that because S390 missed the train when it was
added to mainline in 2007 (, i.e. 11 years _after_ this "undocumented" rule was
established that now 20 years later the world has to revolve around S390
and your personal idea of "clear and intelligible":
> While this is an improvement in some respects the goal to have clear and
> intelligible API around the generic entry is not acheived.
I'm honestly not sure whether I should laugh or cry.
You are completely missing the point:
1) The set in stone rule is that if the entry code returns -1L as the
syscall number then the architecture code has to skip the syscall
invocation _and_ is not supposed to change the return value.
2) There is no guarantee and never has been that any of the involved
mechanisms (ptrace, seccomp, tracing) will change the return value
when it sets the syscall number to -1L.
Quite the contrary there has been a long time (30 years at least)
expectation that the return value has been preset to -ENOSYS.
3) It's trivial as demonstrated to make ptrace and seccomp more
comprehensible but that does not invalidate #2
4) Due to the historical integration of tracing (+probes/BPF) there is
an implicit assumption that the return code is preset to -ENOSYS.
See #2
5) There is an obvious ambiguity between the initial syscall number
being -1 and the change of syscall number to -1 in the case of
tracing, but that's not unique to tracing:
If e.g. seccomp() observes the handed in syscall number to be -1
and tells in the return code to skip the syscall, then it can
rightfully assume that the return code will be -ENOSYS and has no
obligation to set it explicitly. See #2
Q: Is it perfect?
A: No
Q: Can it be made perfect?
A: No, because you can't change history and established practice.
Just for illustration. Changing the logic in trace_syscall_enter() to:
--- a/kernel/entry/syscall-common.c
+++ b/kernel/entry/syscall-common.c
@@ -9,13 +9,15 @@
bool trace_syscall_enter(struct pt_regs *regs, long *syscall)
{
+ long orig_syscall = *syscall;
+
trace_sys_enter(regs, *syscall);
/*
* Probes or BPF hooks in the tracepoint may have changed the
* system call number. Reread it.
*/
*syscall = syscall_get_nr(current, regs);
- return *syscall != -1L;
+ return *syscall == orig_syscall || *syscall != -1L;
}
void trace_syscall_exit(struct pt_regs *regs, long ret)
does not make #2 magically go away. It's still the same problem whether
you like it or not.
Thanks,
tglx
---
Ignorance is bliss -- Thomas Gray, 1742
next prev parent reply other threads:[~2026-07-08 20:34 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
2026-07-07 19:05 ` [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode() Thomas Gleixner
2026-07-08 14:07 ` Shrikanth Hegde
2026-07-08 17:22 ` Radu Rendec
2026-07-09 1:20 ` Jinjie Ruan
2026-07-09 11:12 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff() Thomas Gleixner
2026-07-08 17:24 ` Radu Rendec
2026-07-09 2:13 ` Jinjie Ruan
2026-07-09 16:23 ` Kees Cook
2026-07-07 19:06 ` [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
2026-07-08 17:26 ` Radu Rendec
2026-07-09 2:34 ` Jinjie Ruan
2026-07-09 3:46 ` Jinjie Ruan
2026-07-09 11:15 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack() Thomas Gleixner
2026-07-08 18:37 ` Radu Rendec
2026-07-09 2:37 ` Jinjie Ruan
2026-07-09 11:15 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 05/18] powerpc/syscall: " Thomas Gleixner
2026-07-08 18:35 ` Radu Rendec
2026-07-09 2:38 ` Jinjie Ruan
2026-07-09 11:16 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 06/18] riscv/syscall: " Thomas Gleixner
2026-07-08 20:57 ` Radu Rendec
2026-07-09 2:38 ` Jinjie Ruan
2026-07-09 11:16 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack() Thomas Gleixner
2026-07-08 6:47 ` Sven Schnelle
2026-07-08 20:57 ` Radu Rendec
2026-07-09 2:39 ` Jinjie Ruan
2026-07-09 2:46 ` Jinjie Ruan
2026-07-09 11:17 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
2026-07-08 20:59 ` Radu Rendec
2026-07-09 2:44 ` Jinjie Ruan
2026-07-09 11:18 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 09/18] entry: Remove syscall_enter_from_user_mode() Thomas Gleixner
2026-07-08 21:21 ` Radu Rendec
2026-07-08 22:08 ` Thomas Gleixner
2026-07-09 2:49 ` Jinjie Ruan
2026-07-07 19:06 ` [patch 10/18] entry: Use syscall number instead of rereading it Thomas Gleixner
2026-07-08 21:39 ` Radu Rendec
2026-07-09 2:55 ` Jinjie Ruan
2026-07-09 11:20 ` Philippe Mathieu-Daudé
2026-07-09 11:22 ` Philippe Mathieu-Daudé
2026-07-07 19:06 ` [patch 11/18] seccomp, treewide: Rename and convert __secure_computing() to return boolean Thomas Gleixner
2026-07-08 1:43 ` Jinjie Ruan
2026-07-08 9:15 ` Thomas Gleixner
2026-07-08 16:04 ` Oleg Nesterov
2026-07-08 21:49 ` Thomas Gleixner
2026-07-09 16:22 ` Kees Cook
2026-07-07 19:06 ` [patch 12/18] ptrace, treewide: Rename ptrace_report_syscall_entry() to ptrace_report_syscall_permit_entry() Thomas Gleixner
2026-07-08 15:46 ` Oleg Nesterov
2026-07-09 1:41 ` Jinjie Ruan
2026-07-09 8:41 ` Geert Uytterhoeven
2026-07-09 17:03 ` Radu Rendec
2026-07-07 19:06 ` [patch 13/18] entry: Make trace_syscall_enter() return type bool Thomas Gleixner
2026-07-08 15:52 ` Michal Suchánek
2026-07-08 20:34 ` Thomas Gleixner [this message]
2026-07-08 23:14 ` Thomas Gleixner
2026-07-09 16:26 ` David Laight
2026-07-07 19:06 ` [patch 14/18] entry: Make return type of syscall_trace_enter() bool Thomas Gleixner
2026-07-07 19:06 ` [patch 15/18] x86/entry: Make syscall functions static Thomas Gleixner
2026-07-09 1:47 ` Jinjie Ruan
2026-07-07 19:07 ` [patch 16/18] x86/entry: Get rid of the sys_ni_syscall() indirection Thomas Gleixner
2026-07-09 2:03 ` Jinjie Ruan
2026-07-07 19:07 ` [patch 17/18] x86/entry: Simplify the syscall number logic Thomas Gleixner
2026-07-07 19:07 ` [patch 18/18] entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution Thomas Gleixner
2026-07-08 5:21 ` Shrikanth Hegde
2026-07-08 9:16 ` Thomas Gleixner
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=87se5tqkyp.ffs@fw13 \
--to=tglx@kernel.org \
--cc=andreas@gaisler.com \
--cc=arnd@arndb.de \
--cc=bcain@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=chris@zankel.net \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=deller@gmx.de \
--cc=dinguyen@kernel.org \
--cc=geert@linux-m68k.org \
--cc=guoren@kernel.org \
--cc=kees@kernel.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hexagon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-openrisc@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=linux-um@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=monstr@monstr.eu \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=oleg@redhat.com \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=richard.henderson@linaro.org \
--cc=richard@nod.at \
--cc=ruanjinjie@huawei.com \
--cc=sparclinux@vger.kernel.org \
--cc=sshegde@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=tsbogend@alpha.franken.de \
--cc=vgupta@kernel.org \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=ysato@users.sourceforge.jp \
/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