Re: [PATCH] x86/entry/32: Harden return-to-user

From: Dave Hansen

Date: Tue Oct 27 2026 - 18:04:10 EST


On 10/27/26 14:52, Andrey Zakharov wrote:
> --- a/arch/x86/entry/entry_32.S
> +++ b/arch/x86/entry/entry_32.S
> @@ -952,6 +952,14 @@ restore_all_switch_stack:
>
> /* Restore user state */
> RESTORE_REGS pop=4 # skip orig_eax/error_code
> +
> + /* Assert that the IRET frame returns to user mode or vm86. */
> + testb $USER_SEGMENT_RPL_MASK, 4(%esp)
> + jnz .Lreturn_to_user_ok
> + testl $X86_EFLAGS_VM, 8(%esp)
> + jnz .Lreturn_to_user_ok
> + ud2
> +.Lreturn_to_user_ok:

I'm curious who cares.

Is anyone who is actually still running a 32-bit kernel concerned about
this kind of hardening?

If no one cares, then I'd rather pass on the complexity, even four
instructions of it.