* [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
@ 2026-07-07 19:05 ` Thomas Gleixner
2026-07-08 14:07 ` Shrikanth Hegde
` (4 more replies)
2026-07-07 19:06 ` [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff() Thomas Gleixner
` (20 subsequent siblings)
21 siblings, 5 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:05 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
add_random_kstack_offset() is invoked before syscall_enter_from_user_mode()
establishes state. That's wrong because add_random_kstack_offset() calls
into instrumentable code.
Move it after syscall_enter_from_user_mode() to ensure that state is
correctly established.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/kernel/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -19,8 +19,8 @@ notrace long system_call_exception(struc
long ret;
syscall_fn f;
- add_random_kstack_offset();
r0 = syscall_enter_from_user_mode(regs, r0);
+ add_random_kstack_offset();
if (unlikely(r0 >= NR_syscalls)) {
if (unlikely(trap_is_unsupported_scv(regs))) {
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode()
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
` (3 subsequent siblings)
4 siblings, 0 replies; 107+ messages in thread
From: Shrikanth Hegde @ 2026-07-08 14:07 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/8/26 12:35 AM, Thomas Gleixner wrote:
> add_random_kstack_offset() is invoked before syscall_enter_from_user_mode()
> establishes state. That's wrong because add_random_kstack_offset() calls
> into instrumentable code.
Thanks for fixing that.
>
> Move it after syscall_enter_from_user_mode() to ensure that state is
> correctly established.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -19,8 +19,8 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - add_random_kstack_offset();
> r0 = syscall_enter_from_user_mode(regs, r0);
> + add_random_kstack_offset();
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode()
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
` (2 subsequent siblings)
4 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 17:22 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:05 +0200, Thomas Gleixner wrote:
> add_random_kstack_offset() is invoked before syscall_enter_from_user_mode()
> establishes state. That's wrong because add_random_kstack_offset() calls
> into instrumentable code.
>
> Move it after syscall_enter_from_user_mode() to ensure that state is
> correctly established.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -19,8 +19,8 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - add_random_kstack_offset();
> r0 = syscall_enter_from_user_mode(regs, r0);
> + add_random_kstack_offset();
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode()
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
4 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 1:20 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/8/2026 3:05 AM, Thomas Gleixner wrote:
> add_random_kstack_offset() is invoked before syscall_enter_from_user_mode()
> establishes state. That's wrong because add_random_kstack_offset() calls
> into instrumentable code.
>
> Move it after syscall_enter_from_user_mode() to ensure that state is
> correctly established.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -19,8 +19,8 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - add_random_kstack_offset();
> r0 = syscall_enter_from_user_mode(regs, r0);
> + add_random_kstack_offset();
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode()
2026-07-07 19:05 ` [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode() Thomas Gleixner
` (2 preceding siblings ...)
2026-07-09 1:20 ` Jinjie Ruan
@ 2026-07-09 11:12 ` Philippe Mathieu-Daudé
2026-07-09 18:32 ` Mukesh Kumar Chaurasiya
4 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:12 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/7/26 21:05, Thomas Gleixner wrote:
> add_random_kstack_offset() is invoked before syscall_enter_from_user_mode()
> establishes state. That's wrong because add_random_kstack_offset() calls
> into instrumentable code.
>
> Move it after syscall_enter_from_user_mode() to ensure that state is
> correctly established.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -19,8 +19,8 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - add_random_kstack_offset();
> r0 = syscall_enter_from_user_mode(regs, r0);
> + add_random_kstack_offset();
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode()
2026-07-07 19:05 ` [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode() Thomas Gleixner
` (3 preceding siblings ...)
2026-07-09 11:12 ` Philippe Mathieu-Daudé
@ 2026-07-09 18:32 ` Mukesh Kumar Chaurasiya
4 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:32 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:05:58PM +0200, Thomas Gleixner wrote:
> add_random_kstack_offset() is invoked before syscall_enter_from_user_mode()
> establishes state. That's wrong because add_random_kstack_offset() calls
> into instrumentable code.
>
> Move it after syscall_enter_from_user_mode() to ensure that state is
> correctly established.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
Thanks for fixing this.
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
[...]
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff()
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-07 19:06 ` Thomas Gleixner
2026-07-08 17:24 ` Radu Rendec
` (3 more replies)
2026-07-07 19:06 ` [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
` (19 subsequent siblings)
21 siblings, 4 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Kees Cook, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
add_random_kstack_offset() uses get/put_cpu_var() which is pointless
overhead when it is invoked from low level entry code with interrupts
disabled.
Provide a irqsoff() variant, which avoids that.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Kees Cook <kees@kernel.org>
---
include/linux/randomize_kstack.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- a/include/linux/randomize_kstack.h
+++ b/include/linux/randomize_kstack.h
@@ -77,8 +77,27 @@ static __always_inline u32 get_kstack_of
} \
} while (0)
+/**
+ * add_random_kstack_offset_irqsoff - Increase stack utilization by a random offset.
+ *
+ * This should be used in the syscall entry path after user registers have been
+ * stored to the stack. Interrupts must be still disabled.
+ */
+#define add_random_kstack_offset_irqsoff() \
+do { \
+ lockdep_assert_irqs_disabled(); \
+ if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \
+ &randomize_kstack_offset)) { \
+ u32 offset = prandom_u32_state(raw_cpu_ptr(&kstack_rnd_state)); \
+ u8 *ptr = __kstack_alloca(KSTACK_OFFSET_MAX(offset)); \
+ /* Keep allocation even after "ptr" loses scope. */ \
+ asm volatile("" :: "r"(ptr) : "memory"); \
+ } \
+} while (0)
+
#else /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
#define add_random_kstack_offset() do { } while (0)
+#define add_random_kstack_offset_irqsoff() do { } while (0)
#endif /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
#endif
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff()
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
` (2 subsequent siblings)
3 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 17:24 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Kees Cook, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> add_random_kstack_offset() uses get/put_cpu_var() which is pointless
> overhead when it is invoked from low level entry code with interrupts
> disabled.
>
> Provide a irqsoff() variant, which avoids that.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Kees Cook <kees@kernel.org>
> ---
> include/linux/randomize_kstack.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> --- a/include/linux/randomize_kstack.h
> +++ b/include/linux/randomize_kstack.h
> @@ -77,8 +77,27 @@ static __always_inline u32 get_kstack_of
> } \
> } while (0)
>
> +/**
> + * add_random_kstack_offset_irqsoff - Increase stack utilization by a random offset.
> + *
> + * This should be used in the syscall entry path after user registers have been
> + * stored to the stack. Interrupts must be still disabled.
> + */
> +#define add_random_kstack_offset_irqsoff() \
> +do { \
> + lockdep_assert_irqs_disabled(); \
> + if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \
> + &randomize_kstack_offset)) { \
> + u32 offset = prandom_u32_state(raw_cpu_ptr(&kstack_rnd_state)); \
> + u8 *ptr = __kstack_alloca(KSTACK_OFFSET_MAX(offset)); \
> + /* Keep allocation even after "ptr" loses scope. */ \
> + asm volatile("" :: "r"(ptr) : "memory"); \
> + } \
> +} while (0)
> +
> #else /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
> #define add_random_kstack_offset() do { } while (0)
> +#define add_random_kstack_offset_irqsoff() do { } while (0)
> #endif /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
>
> #endif
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff()
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
3 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:13 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Kees Cook, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
Mark Rutland, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> add_random_kstack_offset() uses get/put_cpu_var() which is pointless
> overhead when it is invoked from low level entry code with interrupts
> disabled.
>
> Provide a irqsoff() variant, which avoids that.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Kees Cook <kees@kernel.org>
> ---
> include/linux/randomize_kstack.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> --- a/include/linux/randomize_kstack.h
> +++ b/include/linux/randomize_kstack.h
> @@ -77,8 +77,27 @@ static __always_inline u32 get_kstack_of
> } \
> } while (0)
>
> +/**
> + * add_random_kstack_offset_irqsoff - Increase stack utilization by a random offset.
> + *
> + * This should be used in the syscall entry path after user registers have been
> + * stored to the stack. Interrupts must be still disabled.
> + */
> +#define add_random_kstack_offset_irqsoff() \
> +do { \
> + lockdep_assert_irqs_disabled(); \
> + if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \
> + &randomize_kstack_offset)) { \
> + u32 offset = prandom_u32_state(raw_cpu_ptr(&kstack_rnd_state)); \
> + u8 *ptr = __kstack_alloca(KSTACK_OFFSET_MAX(offset)); \
> + /* Keep allocation even after "ptr" loses scope. */ \
> + asm volatile("" :: "r"(ptr) : "memory"); \
> + } \
> +} while (0)
Or can we avoid these repetitions and reuse the same code?
> +
> #else /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
> #define add_random_kstack_offset() do { } while (0)
> +#define add_random_kstack_offset_irqsoff() do { } while (0)
> #endif /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
>
> #endif
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff()
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
3 siblings, 0 replies; 107+ messages in thread
From: Kees Cook @ 2026-07-09 16:23 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:02PM +0200, Thomas Gleixner wrote:
> add_random_kstack_offset() uses get/put_cpu_var() which is pointless
> overhead when it is invoked from low level entry code with interrupts
> disabled.
>
> Provide a irqsoff() variant, which avoids that.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Seems good. I don't think macro'izing the interior is worth it since
both cases are very short, with only the lockdep and raw bits changed.
Reviewed-by: Kees Cook <kees@kernel.org>
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 107+ messages in thread
* Re: [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff()
2026-07-07 19:06 ` [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff() Thomas Gleixner
` (2 preceding siblings ...)
2026-07-09 16:23 ` Kees Cook
@ 2026-07-09 18:34 ` Mukesh Kumar Chaurasiya
3 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:34 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Kees Cook, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, Sven Schnelle,
linux-s390, x86, 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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:02PM +0200, Thomas Gleixner wrote:
> add_random_kstack_offset() uses get/put_cpu_var() which is pointless
> overhead when it is invoked from low level entry code with interrupts
> disabled.
>
> Provide a irqsoff() variant, which avoids that.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Kees Cook <kees@kernel.org>
> ---
> include/linux/randomize_kstack.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> --- a/include/linux/randomize_kstack.h
> +++ b/include/linux/randomize_kstack.h
> @@ -77,8 +77,27 @@ static __always_inline u32 get_kstack_of
> } \
> } while (0)
>
> +/**
> + * add_random_kstack_offset_irqsoff - Increase stack utilization by a random offset.
> + *
> + * This should be used in the syscall entry path after user registers have been
> + * stored to the stack. Interrupts must be still disabled.
> + */
> +#define add_random_kstack_offset_irqsoff() \
> +do { \
> + lockdep_assert_irqs_disabled(); \
> + if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \
> + &randomize_kstack_offset)) { \
> + u32 offset = prandom_u32_state(raw_cpu_ptr(&kstack_rnd_state)); \
> + u8 *ptr = __kstack_alloca(KSTACK_OFFSET_MAX(offset)); \
> + /* Keep allocation even after "ptr" loses scope. */ \
> + asm volatile("" :: "r"(ptr) : "memory"); \
> + } \
> +} while (0)
> +
> #else /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
> #define add_random_kstack_offset() do { } while (0)
> +#define add_random_kstack_offset_irqsoff() do { } while (0)
> #endif /* CONFIG_RANDOMIZE_KSTACK_OFFSET */
>
> #endif
>
LGTM.
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
>
> _______________________________________________
> linux-snps-arc mailing list
> linux-snps-arc@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
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-07 19:06 ` [patch 02/18] randomize_kstack: Provide add_random_kstack_offset_irqsoff() Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 17:26 ` Radu Rendec
` (5 more replies)
2026-07-07 19:06 ` [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack() Thomas Gleixner
` (18 subsequent siblings)
21 siblings, 6 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
Randomizing the syscall stack can only happen after state is established
via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
it happens the better.
Provide two new macros to consolidate that:
- enter_from_user_mode_randomize_stack()
enter_from_user_mode();
add_random_kstack_offset_irqsoff();
- syscall_enter_from_user_mode_randomize_stack()
enter_from_user_mode_randomize_stack();
syscall_enter_from_user_mode_work();
to reduce boiler plate code.
Those are macros and not inline functions as the latter would limit the
stack randomization scope to the inline function itself.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
---
include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -6,6 +6,7 @@
#include <linux/irq-entry-common.h>
#include <linux/livepatch.h>
#include <linux/ptrace.h>
+#include <linux/randomize_kstack.h>
#include <linux/resume_user_mode.h>
#include <linux/seccomp.h>
#include <linux/sched.h>
@@ -150,6 +151,61 @@ static __always_inline long syscall_ente
}
/**
+ * enter_from_user_mode_randomize_stack - Establish state and add stack randomization
+ * before invoking syscall_enter_from_user_mode_work()
+ * @regs: Pointer to currents pt_regs
+ *
+ * Invoked from architecture specific syscall entry code with interrupts
+ * disabled. The calling code has to be non-instrumentable. When the function
+ * returns all state is correct, interrupts are still disabled and the
+ * subsequent functions can be instrumented.
+ *
+ * Implemented as a macro so that the stack randomization is effective
+ * throughout the function in which it is invoked. An inline would only make it
+ * effective in the scope of the inline function.
+ */
+#define enter_from_user_mode_randomize_stack(regs) \
+do { \
+ enter_from_user_mode(regs); \
+ instrumentation_begin(); \
+ add_random_kstack_offset_irqsoff(); \
+ instrumentation_end(); \
+} while (0)
+
+/**
+ * syscall_enter_from_user_mode_randomize_stack - Establish state and check and handle work
+ * before invoking a syscall
+ * @regs: Pointer to currents pt_regs
+ * @syscall: The syscall number
+ *
+ * Invoked from architecture specific syscall entry code with interrupts
+ * disabled. The calling code has to be non-instrumentable. When the
+ * function returns all state is correct, interrupts are enabled and the
+ * subsequent functions can be instrumented.
+ *
+ * This is the combination of enter_from_user_mode_randomize_stack() and
+ * syscall_enter_from_user_mode_work() to be used when there is no
+ * architecture specific work to be done between the two.
+ *
+ * Returns: The original or a modified syscall number. See
+ * syscall_enter_from_user_mode_work() for further explanation.
+ *
+ * Implemented as a macro to make stack randomization effective in the calling
+ * scope.
+ */
+#define syscall_enter_from_user_mode_randomize_stack(regs, syscall) \
+({ \
+ enter_from_user_mode_randomize_stack(regs); \
+ \
+ instrumentation_begin(); \
+ local_irq_enable(); \
+ long _ret = syscall_enter_from_user_mode_work(regs, syscall); \
+ instrumentation_end(); \
+ \
+ _ret; \
+})
+
+/**
* syscall_enter_from_user_mode - Establish state and check and handle work
* before invoking a syscall
* @regs: Pointer to currents pt_regs
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
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
` (4 subsequent siblings)
5 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 17:26 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> Randomizing the syscall stack can only happen after state is established
> via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
> it happens the better.
>
> Provide two new macros to consolidate that:
>
> - enter_from_user_mode_randomize_stack()
> enter_from_user_mode();
> add_random_kstack_offset_irqsoff();
>
> - syscall_enter_from_user_mode_randomize_stack()
> enter_from_user_mode_randomize_stack();
> syscall_enter_from_user_mode_work();
>
> to reduce boiler plate code.
>
> Those are macros and not inline functions as the latter would limit the
> stack randomization scope to the inline function itself.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> ---
> include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -6,6 +6,7 @@
> #include <linux/irq-entry-common.h>
> #include <linux/livepatch.h>
> #include <linux/ptrace.h>
> +#include <linux/randomize_kstack.h>
> #include <linux/resume_user_mode.h>
> #include <linux/seccomp.h>
> #include <linux/sched.h>
> @@ -150,6 +151,61 @@ static __always_inline long syscall_ente
> }
>
> /**
> + * enter_from_user_mode_randomize_stack - Establish state and add stack randomization
> + * before invoking syscall_enter_from_user_mode_work()
> + * @regs: Pointer to currents pt_regs
^^^^^^^^
Nit: current
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the function
> + * returns all state is correct, interrupts are still disabled and the
> + * subsequent functions can be instrumented.
> + *
> + * Implemented as a macro so that the stack randomization is effective
> + * throughout the function in which it is invoked. An inline would only make it
> + * effective in the scope of the inline function.
> + */
> +#define enter_from_user_mode_randomize_stack(regs) \
> +do { \
> + enter_from_user_mode(regs); \
> + instrumentation_begin(); \
> + add_random_kstack_offset_irqsoff(); \
> + instrumentation_end(); \
> +} while (0)
> +
> +/**
> + * syscall_enter_from_user_mode_randomize_stack - Establish state and check and handle work
> + * before invoking a syscall
> + * @regs: Pointer to currents pt_regs
^^^^^^^^
Same here.
> + * @syscall: The syscall number
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the
> + * function returns all state is correct, interrupts are enabled and the
> + * subsequent functions can be instrumented.
> + *
> + * This is the combination of enter_from_user_mode_randomize_stack() and
> + * syscall_enter_from_user_mode_work() to be used when there is no
> + * architecture specific work to be done between the two.
> + *
> + * Returns: The original or a modified syscall number. See
> + * syscall_enter_from_user_mode_work() for further explanation.
> + *
> + * Implemented as a macro to make stack randomization effective in the calling
> + * scope.
> + */
> +#define syscall_enter_from_user_mode_randomize_stack(regs, syscall) \
> +({ \
> + enter_from_user_mode_randomize_stack(regs); \
> + \
> + instrumentation_begin(); \
> + local_irq_enable(); \
> + long _ret = syscall_enter_from_user_mode_work(regs, syscall); \
> + instrumentation_end(); \
> + \
> + _ret; \
> +})
> +
> +/**
> * syscall_enter_from_user_mode - Establish state and check and handle work
> * before invoking a syscall
> * @regs: Pointer to currents pt_regs
With the above nits,
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
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
` (3 subsequent siblings)
5 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:34 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> Randomizing the syscall stack can only happen after state is established
> via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
> it happens the better.
>
> Provide two new macros to consolidate that:
>
> - enter_from_user_mode_randomize_stack()
> enter_from_user_mode();
> add_random_kstack_offset_irqsoff();
>
> - syscall_enter_from_user_mode_randomize_stack()
> enter_from_user_mode_randomize_stack();
> syscall_enter_from_user_mode_work();
>
> to reduce boiler plate code.
>
> Those are macros and not inline functions as the latter would limit the
> stack randomization scope to the inline function itself.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> ---
> include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -6,6 +6,7 @@
> #include <linux/irq-entry-common.h>
> #include <linux/livepatch.h>
> #include <linux/ptrace.h>
> +#include <linux/randomize_kstack.h>
> #include <linux/resume_user_mode.h>
> #include <linux/seccomp.h>
> #include <linux/sched.h>
> @@ -150,6 +151,61 @@ static __always_inline long syscall_ente
> }
>
> /**
> + * enter_from_user_mode_randomize_stack - Establish state and add stack randomization
> + * before invoking syscall_enter_from_user_mode_work()
> + * @regs: Pointer to currents pt_regs
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the function
> + * returns all state is correct, interrupts are still disabled and the
> + * subsequent functions can be instrumented.
> + *
> + * Implemented as a macro so that the stack randomization is effective
> + * throughout the function in which it is invoked. An inline would only make it
> + * effective in the scope of the inline function.
> + */
> +#define enter_from_user_mode_randomize_stack(regs) \
> +do { \
> + enter_from_user_mode(regs); \
> + instrumentation_begin(); \
> + add_random_kstack_offset_irqsoff(); \
> + instrumentation_end(); \
> +} while (0)
> +
> +/**
> + * syscall_enter_from_user_mode_randomize_stack - Establish state and check and handle work
> + * before invoking a syscall
> + * @regs: Pointer to currents pt_regs
> + * @syscall: The syscall number
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the
> + * function returns all state is correct, interrupts are enabled and the
> + * subsequent functions can be instrumented.
> + *
> + * This is the combination of enter_from_user_mode_randomize_stack() and
> + * syscall_enter_from_user_mode_work() to be used when there is no
> + * architecture specific work to be done between the two.
> + *
> + * Returns: The original or a modified syscall number. See
> + * syscall_enter_from_user_mode_work() for further explanation.
> + *
> + * Implemented as a macro to make stack randomization effective in the calling
> + * scope.
> + */
> +#define syscall_enter_from_user_mode_randomize_stack(regs, syscall) \
> +({ \
> + enter_from_user_mode_randomize_stack(regs); \
> + \
> + instrumentation_begin(); \
> + local_irq_enable(); \
> + long _ret = syscall_enter_from_user_mode_work(regs, syscall); \
> + instrumentation_end(); \
> + \
> + _ret; \
> +})
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
> +
> +/**
> * syscall_enter_from_user_mode - Establish state and check and handle work
> * before invoking a syscall
> * @regs: Pointer to currents pt_regs
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
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é
` (2 subsequent siblings)
5 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 3:46 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> Randomizing the syscall stack can only happen after state is established
> via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
> it happens the better.
>
> Provide two new macros to consolidate that:
>
> - enter_from_user_mode_randomize_stack()
> enter_from_user_mode();
> add_random_kstack_offset_irqsoff();
>
> - syscall_enter_from_user_mode_randomize_stack()
> enter_from_user_mode_randomize_stack();
> syscall_enter_from_user_mode_work();
>
> to reduce boiler plate code.
>
> Those are macros and not inline functions as the latter would limit the
> stack randomization scope to the inline function itself.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> ---
> include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -6,6 +6,7 @@
> #include <linux/irq-entry-common.h>
> #include <linux/livepatch.h>
> #include <linux/ptrace.h>
> +#include <linux/randomize_kstack.h>
> #include <linux/resume_user_mode.h>
> #include <linux/seccomp.h>
> #include <linux/sched.h>
> @@ -150,6 +151,61 @@ static __always_inline long syscall_ente
> }
>
> /**
> + * enter_from_user_mode_randomize_stack - Establish state and add stack randomization
> + * before invoking syscall_enter_from_user_mode_work()
> + * @regs: Pointer to currents pt_regs
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the function
> + * returns all state is correct, interrupts are still disabled and the
> + * subsequent functions can be instrumented.
> + *
> + * Implemented as a macro so that the stack randomization is effective
> + * throughout the function in which it is invoked. An inline would only make it
> + * effective in the scope of the inline function.
> + */
> +#define enter_from_user_mode_randomize_stack(regs) \
> +do { \
> + enter_from_user_mode(regs); \
> + instrumentation_begin(); \
> + add_random_kstack_offset_irqsoff(); \
> + instrumentation_end(); \
> +} while (0)
Perhaps this new function can also be reused when the ARM64 is switched
to the generic entry as the irq also disabled now.
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -64,7 +64,7 @@ static void noinstr arm64_exit_to_kernel_mode(struct
pt_regs *regs,
static __always_inline void arm64_syscall_enter_from_user_mode(struct
pt_regs *regs)
{
- enter_from_user_mode(regs);
+ enter_from_user_mode_randomize_stack(regs);
mte_disable_tco_entry(current);
sme_enter_from_user_mode();
}
diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
index e0a98fac3b85..42ac02573b66 100644
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -6,7 +6,6 @@
#include <linux/errno.h>
#include <linux/nospec.h>
#include <linux/ptrace.h>
-#include <linux/randomize_kstack.h>
#include <linux/syscalls.h>
#include <asm/debug-monitors.h>
@@ -42,8 +41,6 @@ static void invoke_syscall(struct pt_regs *regs,
unsigned int scno,
{
long ret;
- add_random_kstack_offset();
-
if (likely(scno < sc_nr)) {
syscall_fn_t syscall_fn;
syscall_fn = syscall_table[array_index_nospec(scno, sc_nr)];
> +
> +/**
> + * syscall_enter_from_user_mode_randomize_stack - Establish state and check and handle work
> + * before invoking a syscall
> + * @regs: Pointer to currents pt_regs
> + * @syscall: The syscall number
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the
> + * function returns all state is correct, interrupts are enabled and the
> + * subsequent functions can be instrumented.
> + *
> + * This is the combination of enter_from_user_mode_randomize_stack() and
> + * syscall_enter_from_user_mode_work() to be used when there is no
> + * architecture specific work to be done between the two.
> + *
> + * Returns: The original or a modified syscall number. See
> + * syscall_enter_from_user_mode_work() for further explanation.
> + *
> + * Implemented as a macro to make stack randomization effective in the calling
> + * scope.
> + */
> +#define syscall_enter_from_user_mode_randomize_stack(regs, syscall) \
> +({ \
> + enter_from_user_mode_randomize_stack(regs); \
> + \
> + instrumentation_begin(); \
> + local_irq_enable(); \
> + long _ret = syscall_enter_from_user_mode_work(regs, syscall); \
> + instrumentation_end(); \
> + \
> + _ret; \
> +})
> +
> +/**
> * syscall_enter_from_user_mode - Establish state and check and handle work
> * before invoking a syscall
> * @regs: Pointer to currents pt_regs
>
^ permalink raw reply related [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
` (2 preceding siblings ...)
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
5 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:15 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/7/26 21:06, Thomas Gleixner wrote:
> Randomizing the syscall stack can only happen after state is established
> via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
> it happens the better.
>
> Provide two new macros to consolidate that:
>
> - enter_from_user_mode_randomize_stack()
> enter_from_user_mode();
> add_random_kstack_offset_irqsoff();
>
> - syscall_enter_from_user_mode_randomize_stack()
> enter_from_user_mode_randomize_stack();
> syscall_enter_from_user_mode_work();
>
> to reduce boiler plate code.
>
> Those are macros and not inline functions as the latter would limit the
> stack randomization scope to the inline function itself.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> ---
> include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
` (3 preceding siblings ...)
2026-07-09 11:15 ` Philippe Mathieu-Daudé
@ 2026-07-09 20:16 ` Mukesh Kumar Chaurasiya
2026-08-27 22:46 ` H. Peter Anvin
5 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 20:16 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:07PM +0200, Thomas Gleixner wrote:
> Randomizing the syscall stack can only happen after state is established
> via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
> it happens the better.
>
> Provide two new macros to consolidate that:
>
> - enter_from_user_mode_randomize_stack()
> enter_from_user_mode();
> add_random_kstack_offset_irqsoff();
>
> - syscall_enter_from_user_mode_randomize_stack()
> enter_from_user_mode_randomize_stack();
> syscall_enter_from_user_mode_work();
>
> to reduce boiler plate code.
>
> Those are macros and not inline functions as the latter would limit the
> stack randomization scope to the inline function itself.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> ---
> include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -6,6 +6,7 @@
> #include <linux/irq-entry-common.h>
> #include <linux/livepatch.h>
> #include <linux/ptrace.h>
> +#include <linux/randomize_kstack.h>
> #include <linux/resume_user_mode.h>
> #include <linux/seccomp.h>
> #include <linux/sched.h>
> @@ -150,6 +151,61 @@ static __always_inline long syscall_ente
> }
>
> /**
> + * enter_from_user_mode_randomize_stack - Establish state and add stack randomization
> + * before invoking syscall_enter_from_user_mode_work()
> + * @regs: Pointer to currents pt_regs
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the function
> + * returns all state is correct, interrupts are still disabled and the
> + * subsequent functions can be instrumented.
> + *
> + * Implemented as a macro so that the stack randomization is effective
> + * throughout the function in which it is invoked. An inline would only make it
> + * effective in the scope of the inline function.
> + */
> +#define enter_from_user_mode_randomize_stack(regs) \
> +do { \
> + enter_from_user_mode(regs); \
> + instrumentation_begin(); \
> + add_random_kstack_offset_irqsoff(); \
> + instrumentation_end(); \
> +} while (0)
> +
> +/**
> + * syscall_enter_from_user_mode_randomize_stack - Establish state and check and handle work
> + * before invoking a syscall
> + * @regs: Pointer to currents pt_regs
> + * @syscall: The syscall number
> + *
> + * Invoked from architecture specific syscall entry code with interrupts
> + * disabled. The calling code has to be non-instrumentable. When the
> + * function returns all state is correct, interrupts are enabled and the
> + * subsequent functions can be instrumented.
> + *
> + * This is the combination of enter_from_user_mode_randomize_stack() and
> + * syscall_enter_from_user_mode_work() to be used when there is no
> + * architecture specific work to be done between the two.
> + *
> + * Returns: The original or a modified syscall number. See
> + * syscall_enter_from_user_mode_work() for further explanation.
> + *
> + * Implemented as a macro to make stack randomization effective in the calling
> + * scope.
> + */
> +#define syscall_enter_from_user_mode_randomize_stack(regs, syscall) \
> +({ \
> + enter_from_user_mode_randomize_stack(regs); \
> + \
> + instrumentation_begin(); \
> + local_irq_enable(); \
> + long _ret = syscall_enter_from_user_mode_work(regs, syscall); \
> + instrumentation_end(); \
> + \
> + _ret; \
> +})
> +
> +/**
> * syscall_enter_from_user_mode - Establish state and check and handle work
> * before invoking a syscall
> * @regs: Pointer to currents pt_regs
>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
>
> _______________________________________________
> linux-snps-arc mailing list
> linux-snps-arc@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
` (4 preceding siblings ...)
2026-07-09 20:16 ` Mukesh Kumar Chaurasiya
@ 2026-08-27 22:46 ` H. Peter Anvin
2026-08-29 21:12 ` Thomas Gleixner
5 siblings, 1 reply; 107+ messages in thread
From: H. Peter Anvin @ 2026-08-27 22:46 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 2026-07-07 12:06, Thomas Gleixner wrote:
> Randomizing the syscall stack can only happen after state is established
> via enter_from_user_mode() or syscall_enter_from_user_mode(). The earlier
> it happens the better.
>
> Provide two new macros to consolidate that:
>
> - enter_from_user_mode_randomize_stack()
> enter_from_user_mode();
> add_random_kstack_offset_irqsoff();
>
> - syscall_enter_from_user_mode_randomize_stack()
> enter_from_user_mode_randomize_stack();
> syscall_enter_from_user_mode_work();
>
> to reduce boiler plate code.
>
> Those are macros and not inline functions as the latter would limit the
> stack randomization scope to the inline function itself.
>
Not directly related to this patchset, but still:
Can anyone *please* find out what the actual security requirements are for the
syscall randomization offset?
The original checkin, 39218ff4c625 ("stack: Optionally randomize kernel stack
offset each syscall") indicates that it is fundamental that the stack offset
is applied *after* pt_regs pushing, but that isn't documented anywhere in the
kernel sources as far as I can tell.
However, I have also come to understand that there are further, undocumented
constraints; at least at one point I was told that "the offset should not be
stored in memory while running in the kernel", which seems more than a bit odd.
This matters, because it creates a data dependency on exit. The original
checkin does call out that RDTSC timing is inappropriate if the user could
control it, but using a hardware CSPRNG like RDRAND (or its equivalent for
other architectures) would be feasible if it isn't in the critical path. If an
RDRAND - store sequence can be executed on entry, *after* the stack
adjustment, then the high latency of RDRAND can hopefully be very effectively
hidden by an OO CPU.
Incidentally, in case you are wondering "why doesn't each core get a dedicated
CSPRNG and hardware randomness generator, to avoid high latency", the answer
is pretty simple: a hardware random number source, regardless of the specifics
of the design, almost by definition violates the hardware design rules of any
digital design; after all, the design rules are designed to *eliminate* noise
(making the circuit behave as closely as physically possible to a realization
of the abstract digital circuit), whereas the very goal of a HWRNG source is
to *extract and amplify* quantum thermal noise. This means that considerable
chip area is consumed by a "keep-out zone", a designated "no man's land"
keeping the digital logic away from the noise source. This keep-out zone is
typically much, much larger than the noise source itself.
-hpa
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()
2026-08-27 22:46 ` H. Peter Anvin
@ 2026-08-29 21:12 ` Thomas Gleixner
0 siblings, 0 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-08-29 21:12 UTC (permalink / raw)
To: H. Peter Anvin, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On Thu, Aug 27 2026 at 15:46, H. Peter Anvin wrote:
> Can anyone *please* find out what the actual security requirements are for the
> syscall randomization offset?
>
> The original checkin, 39218ff4c625 ("stack: Optionally randomize kernel stack
> offset each syscall") indicates that it is fundamental that the stack offset
> is applied *after* pt_regs pushing, but that isn't documented anywhere in the
> kernel sources as far as I can tell.
> However, I have also come to understand that there are further, undocumented
> constraints; at least at one point I was told that "the offset should not be
> stored in memory while running in the kernel", which seems more than a bit odd.
This thread has the initial discussions about it with more explanations:
https://lore.kernel.org/kernel-hardening/2236FBA76BA1254E88B949DDB74E612BA4BC57C1@IRSMSX102.ger.corp.intel.com/
Thanks,
tglx
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
` (2 preceding siblings ...)
2026-07-07 19:06 ` [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 18:37 ` Radu Rendec
` (3 more replies)
2026-07-07 19:06 ` [patch 05/18] powerpc/syscall: " Thomas Gleixner
` (17 subsequent siblings)
21 siblings, 4 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Huacai Chen, loongarch, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
syscall_enter_from_user_mode_randomize_stack() replaces
syscall_enter_from_user_mode() and the subsequent invocation of
add_random_kstack_offset().
The advantage is that it applies the stack randomization right after
enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
as that code is invoked with interrupts disabled.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev
---
arch/loongarch/kernel/syscall.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
--- a/arch/loongarch/kernel/syscall.c
+++ b/arch/loongarch/kernel/syscall.c
@@ -11,7 +11,6 @@
#include <linux/linkage.h>
#include <linux/nospec.h>
#include <linux/objtool.h>
-#include <linux/randomize_kstack.h>
#include <linux/syscalls.h>
#include <linux/unistd.h>
@@ -70,9 +69,7 @@ void noinstr __no_stack_protector do_sys
regs->orig_a0 = regs->regs[4];
regs->regs[4] = -ENOSYS;
- nr = syscall_enter_from_user_mode(regs, nr);
-
- add_random_kstack_offset();
+ nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
if (nr < NR_syscalls) {
syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
` (2 subsequent siblings)
3 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 18:37 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Huacai Chen, loongarch, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: loongarch@lists.linux.dev
> ---
> arch/loongarch/kernel/syscall.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/loongarch/kernel/syscall.c
> +++ b/arch/loongarch/kernel/syscall.c
> @@ -11,7 +11,6 @@
> #include <linux/linkage.h>
> #include <linux/nospec.h>
> #include <linux/objtool.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/syscalls.h>
> #include <linux/unistd.h>
>
> @@ -70,9 +69,7 @@ void noinstr __no_stack_protector do_sys
> regs->orig_a0 = regs->regs[4];
> regs->regs[4] = -ENOSYS;
>
> - nr = syscall_enter_from_user_mode(regs, nr);
> -
> - add_random_kstack_offset();
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
>
> if (nr < NR_syscalls) {
> syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
3 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:37 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Huacai Chen, loongarch, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
Mark Rutland, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: loongarch@lists.linux.dev
> ---
> arch/loongarch/kernel/syscall.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/loongarch/kernel/syscall.c
> +++ b/arch/loongarch/kernel/syscall.c
> @@ -11,7 +11,6 @@
> #include <linux/linkage.h>
> #include <linux/nospec.h>
> #include <linux/objtool.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/syscalls.h>
> #include <linux/unistd.h>
>
> @@ -70,9 +69,7 @@ void noinstr __no_stack_protector do_sys
> regs->orig_a0 = regs->regs[4];
> regs->regs[4] = -ENOSYS;
>
> - nr = syscall_enter_from_user_mode(regs, nr);
> -
> - add_random_kstack_offset();
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> if (nr < NR_syscalls) {
> syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
3 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:15 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Huacai Chen, loongarch, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/7/26 21:06, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: loongarch@lists.linux.dev
> ---
> arch/loongarch/kernel/syscall.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* Re: [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack() Thomas Gleixner
` (2 preceding siblings ...)
2026-07-09 11:15 ` Philippe Mathieu-Daudé
@ 2026-07-09 18:40 ` Mukesh Kumar Chaurasiya
3 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:40 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Huacai Chen, loongarch, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:11PM +0200, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: loongarch@lists.linux.dev
> ---
> arch/loongarch/kernel/syscall.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/loongarch/kernel/syscall.c
> +++ b/arch/loongarch/kernel/syscall.c
> @@ -11,7 +11,6 @@
> #include <linux/linkage.h>
> #include <linux/nospec.h>
> #include <linux/objtool.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/syscalls.h>
> #include <linux/unistd.h>
>
> @@ -70,9 +69,7 @@ void noinstr __no_stack_protector do_sys
> regs->orig_a0 = regs->regs[4];
> regs->regs[4] = -ENOSYS;
>
> - nr = syscall_enter_from_user_mode(regs, nr);
> -
> - add_random_kstack_offset();
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
>
> if (nr < NR_syscalls) {
> syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
>
>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
> _______________________________________________
> linux-snps-arc mailing list
> linux-snps-arc@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 05/18] powerpc/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
` (3 preceding siblings ...)
2026-07-07 19:06 ` [patch 04/18] loongarch/syscall: Use syscall_enter_from_user_mode_randomize_stack() Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 18:35 ` Radu Rendec
` (3 more replies)
2026-07-07 19:06 ` [patch 06/18] riscv/syscall: " Thomas Gleixner
` (16 subsequent siblings)
21 siblings, 4 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
syscall_enter_from_user_mode_randomize_stack() replaces
syscall_enter_from_user_mode() and the subsequent invocation of
add_random_kstack_offset().
The advantage is that it applies the stack randomization right after
enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
as that code is invoked with interrupts disabled.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/kernel/syscall.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -2,7 +2,6 @@
#include <linux/compat.h>
#include <linux/context_tracking.h>
-#include <linux/randomize_kstack.h>
#include <linux/entry-common.h>
#include <asm/interrupt.h>
@@ -19,8 +18,7 @@ notrace long system_call_exception(struc
long ret;
syscall_fn f;
- r0 = syscall_enter_from_user_mode(regs, r0);
- add_random_kstack_offset();
+ r0 = syscall_enter_from_user_mode_randomize_stack(regs, r0);
if (unlikely(r0 >= NR_syscalls)) {
if (unlikely(trap_is_unsupported_scv(regs))) {
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 05/18] powerpc/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
` (2 subsequent siblings)
3 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 18:35 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -2,7 +2,6 @@
>
> #include <linux/compat.h>
> #include <linux/context_tracking.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/entry-common.h>
>
> #include <asm/interrupt.h>
> @@ -19,8 +18,7 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - r0 = syscall_enter_from_user_mode(regs, r0);
> - add_random_kstack_offset();
> + r0 = syscall_enter_from_user_mode_randomize_stack(regs, r0);
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 05/18] powerpc/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
3 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:38 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -2,7 +2,6 @@
>
> #include <linux/compat.h>
> #include <linux/context_tracking.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/entry-common.h>
>
> #include <asm/interrupt.h>
> @@ -19,8 +18,7 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - r0 = syscall_enter_from_user_mode(regs, r0);
> - add_random_kstack_offset();
> + r0 = syscall_enter_from_user_mode_randomize_stack(regs, r0);
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 05/18] powerpc/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
3 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:16 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/7/26 21:06, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* Re: [patch 05/18] powerpc/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 05/18] powerpc/syscall: " Thomas Gleixner
` (2 preceding siblings ...)
2026-07-09 11:16 ` Philippe Mathieu-Daudé
@ 2026-07-09 18:41 ` Mukesh Kumar Chaurasiya
3 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:41 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:15PM +0200, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/syscall.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -2,7 +2,6 @@
>
> #include <linux/compat.h>
> #include <linux/context_tracking.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/entry-common.h>
>
> #include <asm/interrupt.h>
> @@ -19,8 +18,7 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - r0 = syscall_enter_from_user_mode(regs, r0);
> - add_random_kstack_offset();
> + r0 = syscall_enter_from_user_mode_randomize_stack(regs, r0);
>
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
` (4 preceding siblings ...)
2026-07-07 19:06 ` [patch 05/18] powerpc/syscall: " Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 20:57 ` Radu Rendec
` (4 more replies)
2026-07-07 19:06 ` [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack() Thomas Gleixner
` (15 subsequent siblings)
21 siblings, 5 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Paul Walmsley, Palmer Dabbelt, linux-riscv,
Michael Ellerman, Shrikanth Hegde, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
syscall_enter_from_user_mode_randomize_stack() replaces
syscall_enter_from_user_mode() and the subsequent invocation of
add_random_kstack_offset().
The advantage is that it applies the stack randomization right after
enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
as that code is invoked with interrupts disabled.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: linux-riscv@lists.infradead.org
---
arch/riscv/kernel/traps.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -7,7 +7,6 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/irqflags.h>
-#include <linux/randomize_kstack.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/signal.h>
@@ -333,9 +332,7 @@ void do_trap_ecall_u(struct pt_regs *reg
riscv_v_vstate_discard(regs);
- syscall = syscall_enter_from_user_mode(regs, syscall);
-
- add_random_kstack_offset();
+ syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall);
if (syscall >= 0 && syscall < NR_syscalls) {
syscall = array_index_nospec(syscall, NR_syscalls);
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
` (3 subsequent siblings)
4 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 20:57 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Paul Walmsley, Palmer Dabbelt, linux-riscv,
Michael Ellerman, Shrikanth Hegde, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: linux-riscv@lists.infradead.org
> ---
> arch/riscv/kernel/traps.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -7,7 +7,6 @@
> #include <linux/kernel.h>
> #include <linux/init.h>
> #include <linux/irqflags.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/sched.h>
> #include <linux/sched/debug.h>
> #include <linux/sched/signal.h>
> @@ -333,9 +332,7 @@ void do_trap_ecall_u(struct pt_regs *reg
>
> riscv_v_vstate_discard(regs);
>
> - syscall = syscall_enter_from_user_mode(regs, syscall);
> -
> - add_random_kstack_offset();
> + syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall);
>
> if (syscall >= 0 && syscall < NR_syscalls) {
> syscall = array_index_nospec(syscall, NR_syscalls);
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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é
` (2 subsequent siblings)
4 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:38 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Paul Walmsley, Palmer Dabbelt, linux-riscv,
Michael Ellerman, Shrikanth Hegde, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Sven Schnelle, linux-s390, x86,
Mark Rutland, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: linux-riscv@lists.infradead.org
> ---
> arch/riscv/kernel/traps.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -7,7 +7,6 @@
> #include <linux/kernel.h>
> #include <linux/init.h>
> #include <linux/irqflags.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/sched.h>
> #include <linux/sched/debug.h>
> #include <linux/sched/signal.h>
> @@ -333,9 +332,7 @@ void do_trap_ecall_u(struct pt_regs *reg
>
> riscv_v_vstate_discard(regs);
>
> - syscall = syscall_enter_from_user_mode(regs, syscall);
> -
> - add_random_kstack_offset();
> + syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall);
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> if (syscall >= 0 && syscall < NR_syscalls) {
> syscall = array_index_nospec(syscall, NR_syscalls);
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack()
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
4 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:16 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Paul Walmsley, Palmer Dabbelt, linux-riscv,
Michael Ellerman, Shrikanth Hegde, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/7/26 21:06, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: linux-riscv@lists.infradead.org
> ---
> arch/riscv/kernel/traps.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* Re: [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 06/18] riscv/syscall: " Thomas Gleixner
` (2 preceding siblings ...)
2026-07-09 11:16 ` Philippe Mathieu-Daudé
@ 2026-07-09 18:42 ` Mukesh Kumar Chaurasiya
2026-07-13 7:06 ` Guo Ren
4 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:42 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Paul Walmsley, Palmer Dabbelt, linux-riscv,
Michael Ellerman, Shrikanth Hegde, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Sven Schnelle, linux-s390, x86,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:19PM +0200, Thomas Gleixner wrote:
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: linux-riscv@lists.infradead.org
> ---
> arch/riscv/kernel/traps.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -7,7 +7,6 @@
> #include <linux/kernel.h>
> #include <linux/init.h>
> #include <linux/irqflags.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/sched.h>
> #include <linux/sched/debug.h>
> #include <linux/sched/signal.h>
> @@ -333,9 +332,7 @@ void do_trap_ecall_u(struct pt_regs *reg
>
> riscv_v_vstate_discard(regs);
>
> - syscall = syscall_enter_from_user_mode(regs, syscall);
> -
> - add_random_kstack_offset();
> + syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall);
>
> if (syscall >= 0 && syscall < NR_syscalls) {
> syscall = array_index_nospec(syscall, NR_syscalls);
>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 06/18] riscv/syscall: " Thomas Gleixner
` (3 preceding siblings ...)
2026-07-09 18:42 ` Mukesh Kumar Chaurasiya
@ 2026-07-13 7:06 ` Guo Ren
4 siblings, 0 replies; 107+ messages in thread
From: Guo Ren @ 2026-07-13 7:06 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Paul Walmsley, Palmer Dabbelt, linux-riscv,
Michael Ellerman, Shrikanth Hegde, linuxppc-dev, Kees Cook,
Huacai Chen, loongarch, Sven Schnelle, linux-s390, x86,
Mark Rutland, Jinjie Ruan, Andy Lutomirski, Oleg Nesterov,
Richard Henderson, Russell King, Catalin Marinas,
Geert Uytterhoeven, Thomas Bogendoerfer, Helge Deller,
Yoshinori Sato, Richard Weinberger, Chris Zankel,
linux-arm-kernel, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Wed, Jul 8, 2026 at 3:06 AM Thomas Gleixner <tglx@kernel.org> wrote:
>
> syscall_enter_from_user_mode_randomize_stack() replaces
> syscall_enter_from_user_mode() and the subsequent invocation of
> add_random_kstack_offset().
>
> The advantage is that it applies the stack randomization right after
> enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var()
> as that code is invoked with interrupts disabled.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: linux-riscv@lists.infradead.org
> ---
> arch/riscv/kernel/traps.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -7,7 +7,6 @@
> #include <linux/kernel.h>
> #include <linux/init.h>
> #include <linux/irqflags.h>
> -#include <linux/randomize_kstack.h>
> #include <linux/sched.h>
> #include <linux/sched/debug.h>
> #include <linux/sched/signal.h>
> @@ -333,9 +332,7 @@ void do_trap_ecall_u(struct pt_regs *reg
>
> riscv_v_vstate_discard(regs);
>
> - syscall = syscall_enter_from_user_mode(regs, syscall);
> -
> - add_random_kstack_offset();
> + syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall);
Reviewed-by: Guo Ren <guoren@kernel.org>
--
Best Regards
Guo Ren
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
` (5 preceding siblings ...)
2026-07-07 19:06 ` [patch 06/18] riscv/syscall: " Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 6:47 ` Sven Schnelle
` (4 more replies)
2026-07-07 19:06 ` [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
` (14 subsequent siblings)
21 siblings, 5 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Sven Schnelle, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
the subsequent invocation of add_random_kstack_offset_irqsoff().
As a bonus this avoids the overhead of get/put_cpu_var() in
add_random_kstack_offset().
No functional change.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
---
arch/s390/kernel/syscall.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/arch/s390/kernel/syscall.c
+++ b/arch/s390/kernel/syscall.c
@@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
{
unsigned long nr;
- enter_from_user_mode(regs);
- add_random_kstack_offset();
+ enter_from_user_mode_randomize_stack(regs);
+
regs->psw = get_lowcore()->svc_old_psw;
regs->int_code = get_lowcore()->svc_int_code;
update_timer_sys();
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
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
` (3 subsequent siblings)
4 siblings, 0 replies; 107+ messages in thread
From: Sven Schnelle @ 2026-07-08 6:47 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
Thomas Gleixner <tglx@kernel.org> writes:
> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
> the subsequent invocation of add_random_kstack_offset_irqsoff().
>
> As a bonus this avoids the overhead of get/put_cpu_var() in
> add_random_kstack_offset().
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> ---
> arch/s390/kernel/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
> {
> unsigned long nr;
>
> - enter_from_user_mode(regs);
> - add_random_kstack_offset();
> + enter_from_user_mode_randomize_stack(regs);
> +
> regs->psw = get_lowcore()->svc_old_psw;
> regs->int_code = get_lowcore()->svc_int_code;
> update_timer_sys();
Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
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
` (2 subsequent siblings)
4 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 20:57 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Sven Schnelle, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
> the subsequent invocation of add_random_kstack_offset_irqsoff().
>
> As a bonus this avoids the overhead of get/put_cpu_var() in
> add_random_kstack_offset().
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> ---
> arch/s390/kernel/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
> {
> unsigned long nr;
>
> - enter_from_user_mode(regs);
> - add_random_kstack_offset();
> + enter_from_user_mode_randomize_stack(regs);
> +
> regs->psw = get_lowcore()->svc_old_psw;
> regs->int_code = get_lowcore()->svc_int_code;
> update_timer_sys();
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
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 18:43 ` Mukesh Kumar Chaurasiya
4 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:39 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Sven Schnelle, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
> the subsequent invocation of add_random_kstack_offset_irqsoff().
>
> As a bonus this avoids the overhead of get/put_cpu_var() in
> add_random_kstack_offset().
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> ---
> arch/s390/kernel/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
> {
> unsigned long nr;
>
> - enter_from_user_mode(regs);
> - add_random_kstack_offset();
> + enter_from_user_mode_randomize_stack(regs);
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
> +
> regs->psw = get_lowcore()->svc_old_psw;
> regs->int_code = get_lowcore()->svc_int_code;
> update_timer_sys();
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack() Thomas Gleixner
` (2 preceding siblings ...)
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
4 siblings, 1 reply; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:46 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Sven Schnelle, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
> the subsequent invocation of add_random_kstack_offset_irqsoff().
>
> As a bonus this avoids the overhead of get/put_cpu_var() in
> add_random_kstack_offset().
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> ---
> arch/s390/kernel/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
> {
> unsigned long nr;
>
> - enter_from_user_mode(regs);
> - add_random_kstack_offset();
> + enter_from_user_mode_randomize_stack(regs);
The #include <linux/randomize_kstack.h> can be removed.
> +
> regs->psw = get_lowcore()->svc_old_psw;
> regs->int_code = get_lowcore()->svc_int_code;
> update_timer_sys();
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
2026-07-09 2:46 ` Jinjie Ruan
@ 2026-07-09 11:17 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:17 UTC (permalink / raw)
To: Jinjie Ruan, Thomas Gleixner, LKML
Cc: Peter Zijlstra, Sven Schnelle, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, Mark Rutland,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 9/7/26 04:46, Jinjie Ruan wrote:
>
>
> On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
>> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
>> the subsequent invocation of add_random_kstack_offset_irqsoff().
>>
>> As a bonus this avoids the overhead of get/put_cpu_var() in
>> add_random_kstack_offset().
>>
>> No functional change.
>>
>> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
>> Cc: Sven Schnelle <svens@linux.ibm.com>
>> Cc: linux-s390@vger.kernel.org
>> ---
>> arch/s390/kernel/syscall.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> --- a/arch/s390/kernel/syscall.c
>> +++ b/arch/s390/kernel/syscall.c
>> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
>> {
>> unsigned long nr;
>>
>> - enter_from_user_mode(regs);
>> - add_random_kstack_offset();
>> + enter_from_user_mode_randomize_stack(regs);
>
> The #include <linux/randomize_kstack.h> can be removed.
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack() Thomas Gleixner
` (3 preceding siblings ...)
2026-07-09 2:46 ` Jinjie Ruan
@ 2026-07-09 18:43 ` Mukesh Kumar Chaurasiya
4 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:43 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, Sven Schnelle, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:23PM +0200, Thomas Gleixner wrote:
> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
> the subsequent invocation of add_random_kstack_offset_irqsoff().
>
> As a bonus this avoids the overhead of get/put_cpu_var() in
> add_random_kstack_offset().
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> ---
> arch/s390/kernel/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
> {
> unsigned long nr;
>
> - enter_from_user_mode(regs);
> - add_random_kstack_offset();
> + enter_from_user_mode_randomize_stack(regs);
> +
> regs->psw = get_lowcore()->svc_old_psw;
> regs->int_code = get_lowcore()->svc_int_code;
> update_timer_sys();
>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
` (6 preceding siblings ...)
2026-07-07 19:06 ` [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack() Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 20:59 ` Radu Rendec
` (3 more replies)
2026-07-07 19:06 ` [patch 09/18] entry: Remove syscall_enter_from_user_mode() Thomas Gleixner
` (13 subsequent siblings)
21 siblings, 4 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, x86, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
These functions integrate the stack randomization.
syscall_enter_from_user_mode_randomize_stack() has the advantage that the
randomization happens early right after enter_from_user_mode().
In both cases also the overhead of get/put_cpu_var() in
add_random_kstack_offset() is avoided.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: x86@kernel.org
---
arch/x86/entry/syscall_32.c | 19 +++++--------------
arch/x86/entry/syscall_64.c | 3 +--
arch/x86/include/asm/entry-common.h | 1 -
3 files changed, 6 insertions(+), 17 deletions(-)
--- a/arch/x86/entry/syscall_32.c
+++ b/arch/x86/entry/syscall_32.c
@@ -142,10 +142,9 @@ static __always_inline bool int80_is_ext
* int80_is_external() below which calls into the APIC driver.
* Identical for soft and external interrupts.
*/
- enter_from_user_mode(regs);
+ enter_from_user_mode_randomize_stack(regs);
instrumentation_begin();
- add_random_kstack_offset();
/* Validate that this is a soft interrupt to the extent possible */
if (unlikely(int80_is_external()))
@@ -210,11 +209,9 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
{
int nr;
- enter_from_user_mode(regs);
+ enter_from_user_mode_randomize_stack(regs);
instrumentation_begin();
- add_random_kstack_offset();
-
/*
* FRED pushed 0 into regs::orig_ax and regs::ax contains the
* syscall number.
@@ -252,10 +249,10 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
* orig_ax, the int return value truncates it. This matches
* the semantics of syscall_get_nr().
*/
- nr = syscall_enter_from_user_mode(regs, nr);
+ nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
+
instrumentation_begin();
- add_random_kstack_offset();
do_syscall_32_irqs_on(regs, nr);
instrumentation_end();
@@ -268,15 +265,9 @@ static noinstr bool __do_fast_syscall_32
int nr = syscall_32_enter(regs);
int res;
- /*
- * This cannot use syscall_enter_from_user_mode() as it has to
- * fetch EBP before invoking any of the syscall entry work
- * functions.
- */
- enter_from_user_mode(regs);
+ enter_from_user_mode_randomize_stack(regs);
instrumentation_begin();
- add_random_kstack_offset();
local_irq_enable();
/* Fetch EBP from where the vDSO stashed it. */
if (IS_ENABLED(CONFIG_X86_64)) {
--- a/arch/x86/entry/syscall_64.c
+++ b/arch/x86/entry/syscall_64.c
@@ -86,10 +86,9 @@ static __always_inline bool do_syscall_x
/* Returns true to return using SYSRET, or false to use IRET */
__visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr)
{
- nr = syscall_enter_from_user_mode(regs, nr);
+ nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
instrumentation_begin();
- add_random_kstack_offset();
if (!do_syscall_x64(regs, nr) && !do_syscall_x32(regs, nr) && nr != -1) {
/* Invalid system call, but still a system call. */
--- a/arch/x86/include/asm/entry-common.h
+++ b/arch/x86/include/asm/entry-common.h
@@ -2,7 +2,6 @@
#ifndef _ASM_X86_ENTRY_COMMON_H
#define _ASM_X86_ENTRY_COMMON_H
-#include <linux/randomize_kstack.h>
#include <linux/user-return-notifier.h>
#include <asm/nospec-branch.h>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack()
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
` (2 subsequent siblings)
3 siblings, 0 replies; 107+ messages in thread
From: Radu Rendec @ 2026-07-08 20:59 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, x86, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, 2026-07-07 at 21:06 +0200, Thomas Gleixner wrote:
> These functions integrate the stack randomization.
>
> syscall_enter_from_user_mode_randomize_stack() has the advantage that the
> randomization happens early right after enter_from_user_mode().
>
> In both cases also the overhead of get/put_cpu_var() in
> add_random_kstack_offset() is avoided.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: x86@kernel.org
> ---
> arch/x86/entry/syscall_32.c | 19 +++++--------------
> arch/x86/entry/syscall_64.c | 3 +--
> arch/x86/include/asm/entry-common.h | 1 -
> 3 files changed, 6 insertions(+), 17 deletions(-)
>
> --- a/arch/x86/entry/syscall_32.c
> +++ b/arch/x86/entry/syscall_32.c
> @@ -142,10 +142,9 @@ static __always_inline bool int80_is_ext
> * int80_is_external() below which calls into the APIC driver.
> * Identical for soft and external interrupts.
> */
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
>
> /* Validate that this is a soft interrupt to the extent possible */
> if (unlikely(int80_is_external()))
> @@ -210,11 +209,9 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> {
> int nr;
>
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
> -
> /*
> * FRED pushed 0 into regs::orig_ax and regs::ax contains the
> * syscall number.
> @@ -252,10 +249,10 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> * orig_ax, the int return value truncates it. This matches
> * the semantics of syscall_get_nr().
> */
> - nr = syscall_enter_from_user_mode(regs, nr);
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> +
> instrumentation_begin();
>
> - add_random_kstack_offset();
> do_syscall_32_irqs_on(regs, nr);
>
> instrumentation_end();
> @@ -268,15 +265,9 @@ static noinstr bool __do_fast_syscall_32
> int nr = syscall_32_enter(regs);
> int res;
>
> - /*
> - * This cannot use syscall_enter_from_user_mode() as it has to
> - * fetch EBP before invoking any of the syscall entry work
> - * functions.
> - */
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
> local_irq_enable();
> /* Fetch EBP from where the vDSO stashed it. */
> if (IS_ENABLED(CONFIG_X86_64)) {
> --- a/arch/x86/entry/syscall_64.c
> +++ b/arch/x86/entry/syscall_64.c
> @@ -86,10 +86,9 @@ static __always_inline bool do_syscall_x
> /* Returns true to return using SYSRET, or false to use IRET */
> __visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr)
> {
> - nr = syscall_enter_from_user_mode(regs, nr);
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
>
> instrumentation_begin();
> - add_random_kstack_offset();
>
> if (!do_syscall_x64(regs, nr) && !do_syscall_x32(regs, nr) && nr != -1) {
> /* Invalid system call, but still a system call. */
> --- a/arch/x86/include/asm/entry-common.h
> +++ b/arch/x86/include/asm/entry-common.h
> @@ -2,7 +2,6 @@
> #ifndef _ASM_X86_ENTRY_COMMON_H
> #define _ASM_X86_ENTRY_COMMON_H
>
> -#include <linux/randomize_kstack.h>
> #include <linux/user-return-notifier.h>
>
> #include <asm/nospec-branch.h>
Reviewed-by: Radu Rendec <radu@rendec.net>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack()
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
3 siblings, 0 replies; 107+ messages in thread
From: Jinjie Ruan @ 2026-07-09 2:44 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, x86, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390,
Mark Rutland, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
On 7/8/2026 3:06 AM, Thomas Gleixner wrote:
> These functions integrate the stack randomization.
>
> syscall_enter_from_user_mode_randomize_stack() has the advantage that the
> randomization happens early right after enter_from_user_mode().
>
> In both cases also the overhead of get/put_cpu_var() in
> add_random_kstack_offset() is avoided.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: x86@kernel.org
> ---
> arch/x86/entry/syscall_32.c | 19 +++++--------------
> arch/x86/entry/syscall_64.c | 3 +--
> arch/x86/include/asm/entry-common.h | 1 -
> 3 files changed, 6 insertions(+), 17 deletions(-)
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> --- a/arch/x86/entry/syscall_32.c
> +++ b/arch/x86/entry/syscall_32.c
> @@ -142,10 +142,9 @@ static __always_inline bool int80_is_ext
> * int80_is_external() below which calls into the APIC driver.
> * Identical for soft and external interrupts.
> */
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
>
> /* Validate that this is a soft interrupt to the extent possible */
> if (unlikely(int80_is_external()))
> @@ -210,11 +209,9 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> {
> int nr;
>
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
> -
> /*
> * FRED pushed 0 into regs::orig_ax and regs::ax contains the
> * syscall number.
> @@ -252,10 +249,10 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> * orig_ax, the int return value truncates it. This matches
> * the semantics of syscall_get_nr().
> */
> - nr = syscall_enter_from_user_mode(regs, nr);
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> +
> instrumentation_begin();
>
> - add_random_kstack_offset();
> do_syscall_32_irqs_on(regs, nr);
>
> instrumentation_end();
> @@ -268,15 +265,9 @@ static noinstr bool __do_fast_syscall_32
> int nr = syscall_32_enter(regs);
> int res;
>
> - /*
> - * This cannot use syscall_enter_from_user_mode() as it has to
> - * fetch EBP before invoking any of the syscall entry work
> - * functions.
> - */
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
> local_irq_enable();
> /* Fetch EBP from where the vDSO stashed it. */
> if (IS_ENABLED(CONFIG_X86_64)) {
> --- a/arch/x86/entry/syscall_64.c
> +++ b/arch/x86/entry/syscall_64.c
> @@ -86,10 +86,9 @@ static __always_inline bool do_syscall_x
> /* Returns true to return using SYSRET, or false to use IRET */
> __visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr)
> {
> - nr = syscall_enter_from_user_mode(regs, nr);
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
>
> instrumentation_begin();
> - add_random_kstack_offset();
>
> if (!do_syscall_x64(regs, nr) && !do_syscall_x32(regs, nr) && nr != -1) {
> /* Invalid system call, but still a system call. */
> --- a/arch/x86/include/asm/entry-common.h
> +++ b/arch/x86/include/asm/entry-common.h
> @@ -2,7 +2,6 @@
> #ifndef _ASM_X86_ENTRY_COMMON_H
> #define _ASM_X86_ENTRY_COMMON_H
>
> -#include <linux/randomize_kstack.h>
> #include <linux/user-return-notifier.h>
>
> #include <asm/nospec-branch.h>
>
^ permalink raw reply [flat|nested] 107+ messages in thread* Re: [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack()
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
3 siblings, 0 replies; 107+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-09 11:18 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, x86, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On 7/7/26 21:06, Thomas Gleixner wrote:
> These functions integrate the stack randomization.
>
> syscall_enter_from_user_mode_randomize_stack() has the advantage that the
> randomization happens early right after enter_from_user_mode().
>
> In both cases also the overhead of get/put_cpu_var() in
> add_random_kstack_offset() is avoided.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: x86@kernel.org
> ---
> arch/x86/entry/syscall_32.c | 19 +++++--------------
> arch/x86/entry/syscall_64.c | 3 +--
> arch/x86/include/asm/entry-common.h | 1 -
> 3 files changed, 6 insertions(+), 17 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* Re: [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack()
2026-07-07 19:06 ` [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
` (2 preceding siblings ...)
2026-07-09 11:18 ` Philippe Mathieu-Daudé
@ 2026-07-09 18:45 ` Mukesh Kumar Chaurasiya
3 siblings, 0 replies; 107+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-07-09 18:45 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, x86, Michael Ellerman, Shrikanth Hegde,
linuxppc-dev, Kees Cook, Huacai Chen, loongarch, Paul Walmsley,
Palmer Dabbelt, linux-riscv, Sven Schnelle, linux-s390,
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, linux-alpha, linux-csky, linux-m68k, linux-mips,
linux-parisc, linux-sh, linux-um, Arnd Bergmann, Vineet Gupta,
Will Deacon, Brian Cain, Michal Simek, Dinh Nguyen,
David S. Miller, Andreas Larsson, linux-snps-arc, linux-hexagon,
linux-openrisc, sparclinux, linux-arch, Michal Suchánek,
Jonathan Corbet, linux-doc
On Tue, Jul 07, 2026 at 09:06:27PM +0200, Thomas Gleixner wrote:
> These functions integrate the stack randomization.
>
> syscall_enter_from_user_mode_randomize_stack() has the advantage that the
> randomization happens early right after enter_from_user_mode().
>
> In both cases also the overhead of get/put_cpu_var() in
> add_random_kstack_offset() is avoided.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: x86@kernel.org
> ---
> arch/x86/entry/syscall_32.c | 19 +++++--------------
> arch/x86/entry/syscall_64.c | 3 +--
> arch/x86/include/asm/entry-common.h | 1 -
> 3 files changed, 6 insertions(+), 17 deletions(-)
>
> --- a/arch/x86/entry/syscall_32.c
> +++ b/arch/x86/entry/syscall_32.c
> @@ -142,10 +142,9 @@ static __always_inline bool int80_is_ext
> * int80_is_external() below which calls into the APIC driver.
> * Identical for soft and external interrupts.
> */
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
>
> /* Validate that this is a soft interrupt to the extent possible */
> if (unlikely(int80_is_external()))
> @@ -210,11 +209,9 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> {
> int nr;
>
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
> -
> /*
> * FRED pushed 0 into regs::orig_ax and regs::ax contains the
> * syscall number.
> @@ -252,10 +249,10 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> * orig_ax, the int return value truncates it. This matches
> * the semantics of syscall_get_nr().
> */
> - nr = syscall_enter_from_user_mode(regs, nr);
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> +
> instrumentation_begin();
>
> - add_random_kstack_offset();
> do_syscall_32_irqs_on(regs, nr);
>
> instrumentation_end();
> @@ -268,15 +265,9 @@ static noinstr bool __do_fast_syscall_32
> int nr = syscall_32_enter(regs);
> int res;
>
> - /*
> - * This cannot use syscall_enter_from_user_mode() as it has to
> - * fetch EBP before invoking any of the syscall entry work
> - * functions.
> - */
> - enter_from_user_mode(regs);
> + enter_from_user_mode_randomize_stack(regs);
>
> instrumentation_begin();
> - add_random_kstack_offset();
> local_irq_enable();
> /* Fetch EBP from where the vDSO stashed it. */
> if (IS_ENABLED(CONFIG_X86_64)) {
> --- a/arch/x86/entry/syscall_64.c
> +++ b/arch/x86/entry/syscall_64.c
> @@ -86,10 +86,9 @@ static __always_inline bool do_syscall_x
> /* Returns true to return using SYSRET, or false to use IRET */
> __visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr)
> {
> - nr = syscall_enter_from_user_mode(regs, nr);
> + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
>
> instrumentation_begin();
> - add_random_kstack_offset();
>
> if (!do_syscall_x64(regs, nr) && !do_syscall_x32(regs, nr) && nr != -1) {
> /* Invalid system call, but still a system call. */
> --- a/arch/x86/include/asm/entry-common.h
> +++ b/arch/x86/include/asm/entry-common.h
> @@ -2,7 +2,6 @@
> #ifndef _ASM_X86_ENTRY_COMMON_H
> #define _ASM_X86_ENTRY_COMMON_H
>
> -#include <linux/randomize_kstack.h>
> #include <linux/user-return-notifier.h>
>
> #include <asm/nospec-branch.h>
>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
^ permalink raw reply [flat|nested] 107+ messages in thread
* [patch 09/18] entry: Remove syscall_enter_from_user_mode()
2026-07-07 19:05 [patch 00/18] entry: Consolidate and rework syscall entry handling Thomas Gleixner
` (7 preceding siblings ...)
2026-07-07 19:06 ` [patch 08/18] x86/syscall: Use [syscall_]enter_from_user_mode_randomize_stack() Thomas Gleixner
@ 2026-07-07 19:06 ` Thomas Gleixner
2026-07-08 21:21 ` Radu Rendec
` (2 more replies)
2026-07-07 19:06 ` [patch 10/18] entry: Use syscall number instead of rereading it Thomas Gleixner
` (12 subsequent siblings)
21 siblings, 3 replies; 107+ messages in thread
From: Thomas Gleixner @ 2026-07-07 19:06 UTC (permalink / raw)
To: LKML
Cc: Peter Zijlstra, Michael Ellerman, Shrikanth Hegde, linuxppc-dev,
Kees Cook, Huacai Chen, loongarch, Paul Walmsley, Palmer Dabbelt,
linux-riscv, Sven Schnelle, linux-s390, x86, 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, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
All architecture use either:
nr = enter_from_user_mode_randomize_stack(regs, nr);
or
enter_from_user_mode_randomize_stack(regs);
nr = syscall_enter_from_user_mode_work(regs, nr);
Remove the now unused function.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
---
Documentation/core-api/entry.rst | 17 +++++++++-------
include/linux/entry-common.h | 40 +++------------------------------------
include/linux/irq-entry-common.h | 6 ++---
3 files changed, 17 insertions(+), 46 deletions(-)
--- a/Documentation/core-api/entry.rst
+++ b/Documentation/core-api/entry.rst
@@ -68,7 +68,7 @@ low-level C code must not be instrumente
noinstr void syscall(struct pt_regs *regs, int nr)
{
arch_syscall_enter(regs);
- nr = syscall_enter_from_user_mode(regs, nr);
+ nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
instrumentation_begin();
if (!invoke_syscall(regs, nr) && nr != -1)
@@ -78,12 +78,14 @@ low-level C code must not be instrumente
syscall_exit