Skip to content

Commit aa280a0

Browse files
andyhhpPeter Zijlstra
authored andcommitted
x86/fred: Correct speculative safety in fred_extint()
array_index_nospec() is no use if the result gets spilled to the stack, as it makes the believed safe-under-speculation value subject to memory predictions. For all practical purposes, this means array_index_nospec() must be used in the expression that accesses the array. As the code currently stands, it's the wrong side of irqentry_enter(), and 'index' is put into %ebp across the function call. Remove the index variable and reposition array_index_nospec(), so it's calculated immediately before the array access. Fixes: 14619d9 ("x86/fred: FRED entry/exit and dispatch code") Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260106131504.679932-1-andrew.cooper3@citrix.com
1 parent 6de23f8 commit aa280a0

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

arch/x86/entry/entry_fred.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ void __init fred_complete_exception_setup(void)
160160
static noinstr void fred_extint(struct pt_regs *regs)
161161
{
162162
unsigned int vector = regs->fred_ss.vector;
163-
unsigned int index = array_index_nospec(vector - FIRST_SYSTEM_VECTOR,
164-
NR_SYSTEM_VECTORS);
165163

166164
if (WARN_ON_ONCE(vector < FIRST_EXTERNAL_VECTOR))
167165
return;
@@ -170,7 +168,8 @@ static noinstr void fred_extint(struct pt_regs *regs)
170168
irqentry_state_t state = irqentry_enter(regs);
171169

172170
instrumentation_begin();
173-
sysvec_table[index](regs);
171+
sysvec_table[array_index_nospec(vector - FIRST_SYSTEM_VECTOR,
172+
NR_SYSTEM_VECTORS)](regs);
174173
instrumentation_end();
175174
irqentry_exit(regs, state);
176175
} else {

0 commit comments

Comments
 (0)