Re: [patch 03/18] entry: Provide [syscall_]enter_from_user_mode_randomize_stack()

From: Philippe Mathieu-Daudé

Date: Thu Jul 09 2026 - 07:15:57 EST


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@xxxxxxxxxx>
---
include/linux/entry-common.h | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx>