From: sashiko-bot@kernel.org
To: "Thomas Gleixner" <tglx@kernel.org>
Cc: linux-s390@vger.kernel.org, sparclinux@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH] x86/entry: Fix ptrace regression
Date: Sat, 31 Oct 2026 01:32:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-191692@kernel.org> (raw)
In-Reply-To: <87mrrvxaty.ffs@fw13>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/entry: missing nr != -1L check in do_syscall_32_irqs_on()
--
commit 99103a6b0e601cd2293cec25712d5b3e23db9efc
Author: Thomas Gleixner <tglx@kernel.org>
x86/entry: Fix ptrace regression
This commit restores the historical syscall entry behavior of preserving
tracer modifications to regs->ax when a syscall is aborted with -1L while
overwriting regs->ax with -ENOSYS when the syscall number is rewritten to an
invalid value.
Closes: https://lore.kernel.org/all/20261022142425.3Wx-RrU5@linutronix.de
> diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c
> index a59509bb460ab..1f91444d01a8e 100644
> --- a/arch/x86/entry/syscall_32.c
> +++ b/arch/x86/entry/syscall_32.c
> @@ -77,6 +77,8 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs, unsigned
> if (likely(nr < IA32_NR_syscalls)) {
> nr = array_index_nospec(nr, IA32_NR_syscalls);
> regs->ax = ia32_sys_call(regs, (unsigned int)nr);
> + } else {
> + regs->ax = -ENOSYS;
> }
> }
[Severity: High]
Should the else branch in do_syscall_32_irqs_on() in
arch/x86/entry/syscall_32.c also check that nr != -1L before setting
regs->ax = -ENOSYS, matching the check added to do_syscall_64() in
arch/x86/entry/syscall_64.c and the logic prior to commit 1b1f3b3e1b39
("x86/entry: Get rid of the sys_ni_syscall() indirection")?
When a 32-bit syscall (entered via do_int80_emulation(),
fred_int80_emulation(), do_int80_syscall_32(), or __do_fast_syscall_32()) is
traced with PTRACE_SYSCALL without SYSCALL_WORK_SYSCALL_EMU,
syscall_enter_from_user_mode_work() runs:
include/linux/entry-common.h:syscall_enter_from_user_mode_work() {
...
if (unlikely(!syscall_trace_enter(regs, work, *syscall)))
return false;
/* Reread the syscall number as it might have been modified */
*syscall = syscall_get_nr(current, regs);
return true;
}
If the tracer aborts the syscall at the syscall-entry stop by setting
orig_ax to -1 and writing a return value into regs->ax,
syscall_trace_enter() -> arch_ptrace_report_syscall_permit_entry() ->
ptrace_report_syscall_permit_entry() returns true (unless a fatal signal is
pending). syscall_enter_from_user_mode_work() then updates *syscall to -1L
and returns true.
The caller then passes nr == (unsigned long)-1L into
do_syscall_32_irqs_on(), where nr < IA32_NR_syscalls is false and the
unconditional else branch overwrites the tracer-supplied regs->ax value with
-ENOSYS.
--
Sashiko AI review · https://sashiko.dev/#/patchset/87mrrvxaty.ffs@fw13?part=1
next prev parent reply other threads:[~2026-10-31 1:32 UTC|newest]
Thread overview: 125+ 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-09 18:32 ` Mukesh Kumar Chaurasiya
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-09 18:34 ` Mukesh Kumar Chaurasiya
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-09 20:16 ` Mukesh Kumar Chaurasiya
2026-08-27 22:46 ` H. Peter Anvin
2026-08-29 21:12 ` Thomas Gleixner
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-09 18:40 ` Mukesh Kumar Chaurasiya
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-09 18:41 ` Mukesh Kumar Chaurasiya
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-09 18:42 ` Mukesh Kumar Chaurasiya
2026-07-13 7:06 ` Guo Ren
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-09 18:43 ` Mukesh Kumar Chaurasiya
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-09 18:45 ` Mukesh Kumar Chaurasiya
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-09 18:49 ` Mukesh Kumar Chaurasiya
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-09 18:50 ` Mukesh Kumar Chaurasiya
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-09 19:10 ` Mukesh Kumar Chaurasiya
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-09 19:22 ` Mukesh Kumar Chaurasiya
2026-07-10 10:42 ` Michal Suchánek
2026-07-10 11:16 ` Oleg Nesterov
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
2026-07-08 23:14 ` Thomas Gleixner
2026-07-09 16:26 ` David Laight
2026-07-10 11:01 ` Michal Suchánek
2026-07-10 11:40 ` Oleg Nesterov
2026-07-10 12:32 ` Michal Suchánek
2026-07-10 12:52 ` Oleg Nesterov
2026-07-10 15:20 ` Michal Suchánek
2026-07-11 20:33 ` Thomas Gleixner
2026-07-14 8:20 ` Michal Suchánek
2026-07-07 19:06 ` [patch 14/18] entry: Make return type of syscall_trace_enter() bool Thomas Gleixner
2026-07-09 19:36 ` Mukesh Kumar Chaurasiya
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-09 19:43 ` Mukesh Kumar Chaurasiya
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-10-22 14:24 ` Sebastian Andrzej Siewior
2026-10-22 15:02 ` Sebastian Andrzej Siewior
2026-10-22 18:00 ` H. Peter Anvin
2026-10-22 19:15 ` Thomas Gleixner
2026-10-22 21:34 ` Thomas Gleixner
2026-10-23 0:22 ` H. Peter Anvin
2026-10-23 13:09 ` Thomas Gleixner
2026-10-23 14:24 ` Thomas Gleixner
2026-10-23 15:38 ` H. Peter Anvin
2026-10-23 21:03 ` Thomas Gleixner
2026-10-30 19:11 ` [PATCH] x86/entry: Fix ptrace regression Thomas Gleixner
2026-10-31 1:32 ` sashiko-bot [this message]
2026-11-01 17:58 ` [PATCH V2] " Thomas Gleixner
2026-11-01 18:07 ` sashiko-bot
2026-11-03 20:27 ` Thomas Gleixner
2026-11-02 16:21 ` Sebastian Andrzej Siewior
2026-10-23 21:43 ` [patch 16/18] x86/entry: Get rid of the sys_ni_syscall() indirection Sebastian Andrzej Siewior
2026-10-23 15:35 ` H. Peter Anvin
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
2026-07-09 19:49 ` Mukesh Kumar Chaurasiya
2026-07-09 20:15 ` [patch 00/18] entry: Consolidate and rework syscall entry handling Mukesh Kumar Chaurasiya
2026-07-11 12:29 ` Magnus Lindholm
2026-07-19 11:25 ` Magnus Lindholm
2026-07-20 19:21 ` Thomas Gleixner
2026-07-20 22:01 ` Magnus Lindholm
2026-07-21 8:17 ` Thomas Gleixner
2026-08-27 22:22 ` H. Peter Anvin
2026-08-31 8:50 ` Heiko Carstens
2026-08-31 19:57 ` H. Peter Anvin
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=sashiko-outbox-191692@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox