Skip to content

Commit 6376306

Browse files
committed
x86/retpolines: Enable the default thunk warning only on relevant configs
The using-default-thunk warning check makes sense only with configurations which actually enable the special return thunks. Otherwise, it fires on unrelated 32-bit configs on which the special return thunks won't even work (they're 64-bit only) and, what is more, those configs even go off into the weeds when booting in the alternatives patching code, leading to a dead machine. Fixes: 4461438 ("x86/retpoline: Ensure default return thunk isn't used at runtime") Reported-by: Klara Modin <[email protected]> Reported-by: Erhard Furtner <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Tested-by: Klara Modin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/20240413024956.488d474e@yea
1 parent 6912979 commit 6376306

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/lib/retpoline.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,15 @@ SYM_FUNC_END(call_depth_return_thunk)
382382
SYM_CODE_START(__x86_return_thunk)
383383
UNWIND_HINT_FUNC
384384
ANNOTATE_NOENDBR
385+
#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
386+
defined(CONFIG_MITIGATION_SRSO) || \
387+
defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
385388
ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
386389
"jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
390+
#else
391+
ANNOTATE_UNRET_SAFE
392+
ret
393+
#endif
387394
int3
388395
SYM_CODE_END(__x86_return_thunk)
389396
EXPORT_SYMBOL(__x86_return_thunk)

0 commit comments

Comments
 (0)