mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/microcode/AMD: fix read of uninitialized data
@ 2018-04-10 13:41 Colin King
  2018-04-10 14:22 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2018-04-10 13:41 UTC (permalink / raw)
  To: Borislav Petkov, Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently function __load_ucode_amd can assign an uninitialized cp to *ret
if get_builtin_microcode returns false. This could cause function
load_ucode_amd_bsp to attempt to apply the microcode if the garbage data in
cp is non-zero.  Fix this by moving the zero'ing of cp from function
load_ucode_amd_bsp to __load_ucode_amd.

Detected by CoverityScan, CID#1398332 ("Uninitialized scalar variable")

Fixes: 69f5f983001f ("x86/microcode/AMD: Remove AP scanning optimization")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 arch/x86/kernel/cpu/microcode/amd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 0624957aa068..745135699233 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -254,7 +254,7 @@ static bool get_builtin_microcode(struct cpio_data *cp, unsigned int family)
 static void __load_ucode_amd(unsigned int cpuid_1_eax, struct cpio_data *ret)
 {
 	struct ucode_cpu_info *uci;
-	struct cpio_data cp;
+	struct cpio_data cp = { };
 	const char *path;
 	bool use_pa;
 
@@ -279,7 +279,7 @@ static void __load_ucode_amd(unsigned int cpuid_1_eax, struct cpio_data *ret)
 
 void __init load_ucode_amd_bsp(unsigned int cpuid_1_eax)
 {
-	struct cpio_data cp = { };
+	struct cpio_data cp;
 
 	__load_ucode_amd(cpuid_1_eax, &cp);
 	if (!(cp.data && cp.size))
-- 
2.15.1

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

end of thread, other threads:[~2018-04-10 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10 13:41 [PATCH] x86/microcode/AMD: fix read of uninitialized data Colin King
2018-04-10 14:22 ` Dan Carpenter
2018-04-10 15:35   ` Colin Ian King

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

all inboxes | Powered by JetHome®