Linux 7.3 Cleans Up Stack Randomization, Ensures It Happen As Early As Possible

Merged this week for the Linux 7.3 kernel was a big clean-up to the stack randomization code for better security on Linux systems and helping unify some of the architecture-specific code.

Thomas Gleixner of Intel led the work on overhauling the stack randomization code both to the common code as well as PowerPC, LoongArch, RISC-V, s390, and of course x86/x86_64 code. The rework consolidates a lot of the stack randomization code and helps ensure that it happens as early as possible. Gleixner explained in the pull request:
"Consolidate stack randomization for the generic entry code and the architectures using it.

Stack randomization on syscall entry was sprinkled throughout the architecture specific low level entry code and in some cases at the wrong points, e.g. before establishing state, which violates the non-instrumentable constraints of that code.

Clean this u9p by integrating stack randomization into the generic entry code helpers so that it is invoked at the earliest possible point right after establishing state and converting all generic entry code using architecture over."

In addition to the stack randomization clean-up, the pull request also lands the code for making system call user dispatch "SUD" more configurable such as when wanting to disable it in the name of security. There is now the CONFIG_SYSCALL_USER_DISPATCH Kconfig option to disable at build-time or kernel.syscall_user_dispatch can be used for controlling Syscall User Dispatch at run-time.