Skip to content
Snippets Groups Projects
Commit fb9dc79c authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov
Browse files

x86/entry_32: Fix segment exceptions

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2119111



commit 9cdbeec4
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Tue Jan 11 12:11:14 2022 +0100

    x86/entry_32: Fix segment exceptions

    The LKP robot reported that commit in Fixes: caused a failure. Turns out
    the ldt_gdt_32 selftest turns into an infinite loop trying to clear the
    segment.

    As discovered by Sean, what happens is that PARANOID_EXIT_TO_KERNEL_MODE
    in the handle_exception_return path overwrites the entry stack data with
    the task stack data, restoring the "bad" segment value.

    Instead of having the exception retry the instruction, have it emulate
    the full instruction. Replace EX_TYPE_POP_ZERO with EX_TYPE_POP_REG
    which will do the equivalent of: POP %reg; MOV $imm, %reg.

    In order to encode the segment registers, add them as registers 8-11 for
    32-bit.

    By setting regs->[defg]s the (nested) RESTORE_REGS will pop this value
    at the end of the exception handler and by increasing regs->sp, it will
    have skipped the stack slot.

    This was debugged by Sean Christopherson <seanjc@google.com>.

     [ bp: Add EX_REG_GS too. ]

    Fixes: aa93e2ad ("x86/entry_32: Remove .fixup usage")
Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/Yd1l0gInc4zRcnt/@hirez.programming.kicks-ass.net



Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
parent 3112f795
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment