Skip to content

Commit 333286e

Browse files
dvdgomezPlaidCat
authored andcommitted
x86/nospec: Fix i386 RSB stuffing
jira LE-958 cve-bugfix CVE-2022-26373 commit 3329249 Turns out that i386 doesn't unconditionally have LFENCE, as such the loop in __FILL_RETURN_BUFFER isn't actually speculation safe on such chips. Fixes: ba6e31a ("x86/speculation: Add LFENCE to RSB fill sequence") Reported-by: Ben Hutchings <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected] (cherry picked from commit 3329249) Signed-off-by: David Gomez <[email protected]>
1 parent ae6b4bb commit 333286e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/x86/include/asm/nospec-branch.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* the optimal version - two calls, each with their own speculation
5858
* trap should their return address end up getting used, in a loop.
5959
*/
60+
#ifdef CONFIG_X86_64
6061
#define __FILL_RETURN_BUFFER(reg, nr) \
6162
mov $(nr/2), reg; \
6263
771: \
@@ -67,6 +68,17 @@
6768
jnz 771b; \
6869
/* barrier for jnz misprediction */ \
6970
lfence;
71+
#else
72+
/*
73+
* i386 doesn't unconditionally have LFENCE, as such it can't
74+
* do a loop.
75+
*/
76+
#define __FILL_RETURN_BUFFER(reg, nr) \
77+
.rept nr; \
78+
__FILL_RETURN_SLOT; \
79+
.endr; \
80+
add $(BITS_PER_LONG/8) * nr, %_ASM_SP;
81+
#endif
7082

7183
/*
7284
* Stuff a single RSB slot.

0 commit comments

Comments
 (0)