Skip to content

Commit 978e134

Browse files
aeglKAGA-KOKO
authored andcommitted
x86/speculation/swapgs: Check FSGSBASE in enabling SWAPGS mitigation
Before enabling FSGSBASE the kernel could safely assume that the content of GS base was a user address. Thus any speculative access as the result of a mispredicted branch controlling the execution of SWAPGS would be to a user address. So systems with speculation-proof SMAP did not need to add additional LFENCE instructions to mitigate. With FSGSBASE enabled a hostile user can set GS base to a kernel address. So they can make the kernel speculatively access data they wish to leak via a side channel. This means that SMAP provides no protection. Add FSGSBASE as an additional condition to enable the fence-based SWAPGS mitigation. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Chang S. Bae <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 005f141 commit 978e134

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,12 @@ static void __init spectre_v1_select_mitigation(void)
543543
* If FSGSBASE is enabled, the user can put a kernel address in
544544
* GS, in which case SMAP provides no protection.
545545
*
546-
* [ NOTE: Don't check for X86_FEATURE_FSGSBASE until the
547-
* FSGSBASE enablement patches have been merged. ]
548-
*
549546
* If FSGSBASE is disabled, the user can only put a user space
550547
* address in GS. That makes an attack harder, but still
551548
* possible if there's no SMAP protection.
552549
*/
553-
if (!smap_works_speculatively()) {
550+
if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
551+
!smap_works_speculatively()) {
554552
/*
555553
* Mitigation can be provided from SWAPGS itself or
556554
* PTI as the CR3 write in the Meltdown mitigation

0 commit comments

Comments
 (0)