A warning message is emitted in set_return_thunk() when the return thunk is overwritten since this is likely a bug and will result in a mitigation not functioning and the mitigation information displayed in sysfs being incorrect.
Make this louder by using a WARN().
Cc: stable@vger.kernel.org # 5.15.x- Signed-off-by: Suraj Jitindar Singh surajjs@amazon.com --- arch/x86/kernel/cpu/bugs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 8596ce85026c..9679fa30563c 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -69,8 +69,15 @@ void (*x86_return_thunk)(void) __ro_after_init = __x86_return_thunk;
static void __init set_return_thunk(void *thunk) { - if (x86_return_thunk != __x86_return_thunk) - pr_warn("x86/bugs: return thunk changed\n"); + /* + * There can only be one return thunk enabled at a time, so issue a + * warning when overwriting it as this is likely a bug which will + * result in a mitigation getting disabled and a vulnerability being + * incorrectly reported in sysfs. + */ + WARN(x86_return_thunk != __x86_return_thunk, + "x86/bugs: return thunk changed from %ps to %ps\n", + x86_return_thunk, thunk);
x86_return_thunk = thunk; }