Skip to content
Snippets Groups Projects
Commit 1a9e4174 authored by Waiman Long's avatar Waiman Long
Browse files

x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry()

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



commit c07e4555
Author: Lai Jiangshan <laijs@linux.alibaba.com>
Date:   Fri, 26 Nov 2021 18:11:21 +0800

    x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry()

    Commit

      18ec54fd ("x86/speculation: Prepare entry code for Spectre v1 swapgs mitigations")

    added FENCE_SWAPGS_{KERNEL|USER}_ENTRY for conditional SWAPGS. In
    paranoid_entry(), it uses only FENCE_SWAPGS_KERNEL_ENTRY for both
    branches. This is because the fence is required for both cases since the
    CR3 write is conditional even when PTI is enabled.

    But

      96b23714 ("x86/entry/64: Switch CR3 before SWAPGS in paranoid entry")

    changed the order of SWAPGS and the CR3 write. And it missed the needed
    FENCE_SWAPGS_KERNEL_ENTRY for the user gsbase case.

    Add it back by changing the branches so that FENCE_SWAPGS_KERNEL_ENTRY
    can cover both branches.

      [ bp: Massage, fix typos, remove obsolete comment while at it. ]

    Fixes: 96b23714 ("x86/entry/64: Switch CR3 before SWAPGS in paranoid entry")
Signed-off-by: default avatarLai Jiangshan <laijs@linux.alibaba.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lkml.kernel.org/r/20211126101209.8613-2-jiangshanlai@gmail.com



Signed-off-by: default avatarWaiman Long <longman@redhat.com>
parent c4b23cb3
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