public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: also disable FSRM if ERMS is disabled
@ 2022-09-23  0:58 Daniel Verkamp
  2022-09-23 11:13 ` Borislav Petkov
  0 siblings, 1 reply; 18+ messages in thread
From: Daniel Verkamp @ 2022-09-23  0:58 UTC (permalink / raw)
  To: x86, linux-kernel; +Cc: Tony Luck, Borislav Petkov, Daniel Verkamp, stable

In the "Fast Short REP MOVSB" path of memmove, if we take the path where
the FSRM flag is enabled but the ERMS flag is not, there is no longer a
check for length >= 0x20 (both alternatives will be replaced with NOPs).
If a memmove() requiring a forward copy of less than 0x20 bytes happens
in this case, the `sub $0x20, %rdx` will cause the length to roll around
to a huge value and the copy will eventually hit a page fault.

This is not intended to happen, as the comment above the alternatives
mentions "FSRM implies ERMS".

However, there is a check in early_init_intel() that can disable ERMS,
so we should also be disabling FSRM in this path to maintain correctness
of the memmove() optimization.

Cc: stable@vger.kernel.org
Fixes: f444a5ff95dc ("x86/cpufeatures: Add support for fast short REP; MOVSB")
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
---
 arch/x86/kernel/cpu/intel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 2d7ea5480ec3..71b412f820c7 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -328,6 +328,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 			pr_info("Disabled fast string operations\n");
 			setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
 			setup_clear_cpu_cap(X86_FEATURE_ERMS);
+			setup_clear_cpu_cap(X86_FEATURE_FSRM);
 		}
 	}
 
-- 
2.37.3.998.g577e59143f-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-01-16 21:17 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-23  0:58 [PATCH] x86: also disable FSRM if ERMS is disabled Daniel Verkamp
2022-09-23 11:13 ` Borislav Petkov
2022-09-23 17:25   ` Daniel Verkamp
2022-09-23 17:51     ` Borislav Petkov
2022-10-07 18:08       ` Daniel Verkamp
2022-10-11 11:28         ` Borislav Petkov
2022-10-11 17:09           ` Luck, Tony
2022-10-11 17:52             ` Borislav Petkov
2022-10-11 19:08               ` Luck, Tony
2022-10-11 20:56                 ` Borislav Petkov
2022-10-11 22:19                   ` Luck, Tony
2022-10-11 22:59                     ` Andrew Cooper
2023-01-04  7:43         ` Jiri Slaby
2023-01-04 11:39           ` Borislav Petkov
2023-01-14  9:19             ` Ingo Molnar
2023-01-14  9:58               ` Borislav Petkov
2023-01-16  5:26             ` Jiri Slaby
2023-01-16 21:17               ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox