From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6387440926D for ; Wed, 8 Jul 2026 15:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783525967; cv=none; b=MLqthuWbIkEeGBBW+J4puw/7jEZB21Q8AGyT4k6JBejlZdgHuSELjpKRRVtJW/JtRy3loLbP2cBEX70a9qIwiCDyltrN9PMiS4FvnMgCp4T7h7vXUvaWaIgpV1fPAwXMVnzrnsoa8SuKriFKq3WukDD3AqKuA2YqpaC+FhcQ9cA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783525967; c=relaxed/simple; bh=m2OZqoO4cKfu++qdZ7oxKivY75OzyGZodvLMx4WbbJo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KO80PcTJUMGGzdGOiMeuAJ6EpD6NQXcMWn8oPq/wRkGcKx7zbN7jvWBXTWutKB2Cb9lEWA6uJYog0BXn+zcMkVANyYYeXJwZjtPclIfnhKiFhpAqE4VoYhnY4bfp/5qVQAOKcRQtdLe4YQQZA0/cTVi9LGl1+Mc1akdoBmEBEuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from kunlun.suse.cz (unknown [IPv6:2a07:de40:b306:2000::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C55F775A94; Wed, 8 Jul 2026 15:52:43 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Date: Wed, 8 Jul 2026 17:52:42 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Thomas Gleixner Cc: LKML , Peter Zijlstra , Michael Ellerman , Shrikanth Hegde , linuxppc-dev@lists.ozlabs.org, Kees Cook , Huacai Chen , loongarch@lists.linux.dev, Paul Walmsley , Palmer Dabbelt , linux-riscv@lists.infradead.org, Sven Schnelle , linux-s390@vger.kernel.org, x86@kernel.org, Mark Rutland , Jinjie Ruan , Andy Lutomirski , Oleg Nesterov , Richard Henderson , Russell King , Catalin Marinas , Guo Ren , Geert Uytterhoeven , Thomas Bogendoerfer , Helge Deller , Yoshinori Sato , Richard Weinberger , Chris Zankel , 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 , Vineet Gupta , Will Deacon , Brian Cain , Michal Simek , Dinh Nguyen , "David S. Miller" , Andreas Larsson , 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 , linux-doc@vger.kernel.org Subject: Re: [patch 13/18] entry: Make trace_syscall_enter() return type bool Message-ID: References: <20260707181957.433213175@kernel.org> <20260707190254.338083894@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260707190254.338083894@kernel.org> X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: C55F775A94 X-Spam-Flag: NO X-Spam-Score: -2.00 X-Spam-Level: X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-2.00 / 50.00]; REPLY(-4.00)[]; RDNS_NONE(2.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLs1yuyu6ywojxyk8y3ncu5g39)] Hello, 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. 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 aligns with ptrace_report_syscall_permit_enter() and > seccomp_permit_syscall(). > > 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. While this is an improvement in some respects the goal to have clear and intelligible API around the generic entry is not acheived. Thanks Michal > > Signed-off-by: Thomas Gleixner > --- > include/linux/entry-common.h | 8 +++++--- > kernel/entry/syscall-common.c | 7 ++++--- > 2 files changed, 9 insertions(+), 6 deletions(-) > > --- a/include/linux/entry-common.h > +++ b/include/linux/entry-common.h > @@ -58,7 +58,7 @@ static __always_inline bool arch_ptrace_ > #endif > > bool syscall_user_dispatch(struct pt_regs *regs); > -long trace_syscall_enter(struct pt_regs *regs, long syscall); > +bool trace_syscall_enter(struct pt_regs *regs, long *syscall); > void trace_syscall_exit(struct pt_regs *regs, long ret); > > static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) > @@ -108,8 +108,10 @@ static __always_inline long syscall_trac > /* Either of the above might have changed the syscall number */ > syscall = syscall_get_nr(current, regs); > > - if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT)) > - syscall = trace_syscall_enter(regs, syscall); > + if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT)) { > + if (!trace_syscall_enter(regs, &syscall)) > + return -1L; > + } > > syscall_enter_audit(regs, syscall); > > --- a/kernel/entry/syscall-common.c > +++ b/kernel/entry/syscall-common.c > @@ -7,14 +7,15 @@ > > /* Out of line to prevent tracepoint code duplication */ > > -long trace_syscall_enter(struct pt_regs *regs, long syscall) > +bool trace_syscall_enter(struct pt_regs *regs, long *syscall) > { > - trace_sys_enter(regs, syscall); > + trace_sys_enter(regs, *syscall); > /* > * Probes or BPF hooks in the tracepoint may have changed the > * system call number. Reread it. > */ > - return syscall_get_nr(current, regs); > + *syscall = syscall_get_nr(current, regs); > + return *syscall != -1L; > } > > void trace_syscall_exit(struct pt_regs *regs, long ret) >