All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/mm: Fix use of uninitialized buffer in sme_enable()
@ 2023-02-02 18:25 Nikita Zhandarovich
  2023-02-17 21:47 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Nikita Zhandarovich @ 2023-02-02 18:25 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Nikita Zhandarovich, Andy Lutomirski, Peter Zijlstra,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, Kirill A. Shutemov, Tom Lendacky, linux-kernel,
	lvc-project

cmdline_find_option() may fail before doing any initialization of
buffer array. This may lead to unpredictable results when the same
buffer is used later in calls to strncmp() function.
Fix the issue by initializing the buffer to an empty string.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 1cd9c22fee3a ("x86/mm/encrypt: Move page table helpers into separate translation unit")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
---
 arch/x86/mm/mem_encrypt_identity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c
index 88cccd65029d..6b84243bfd54 100644
--- a/arch/x86/mm/mem_encrypt_identity.c
+++ b/arch/x86/mm/mem_encrypt_identity.c
@@ -509,7 +509,7 @@ void __init sme_enable(struct boot_params *bp)
 	unsigned long feature_mask;
 	bool active_by_default;
 	unsigned long me_mask;
-	char buffer[16];
+	char buffer[16] = "";
 	bool snp;
 	u64 msr;
 
-- 
2.25.1


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02 18:25 [PATCH] x86/mm: Fix use of uninitialized buffer in sme_enable() Nikita Zhandarovich
2023-02-17 21:47 ` Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.