Skip to content

Commit cbebd68

Browse files
Nikita Zhandarovichbp3tk0v
authored andcommitted
x86/mm: Fix use of uninitialized buffer in sme_enable()
cmdline_find_option() may fail before doing any initialization of the buffer array. This may lead to unpredictable results when the same buffer is used later in calls to strncmp() function. Fix the issue by returning early if cmdline_find_option() returns an error. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: aca20d5 ("x86/mm: Add support to make use of Secure Memory Encryption") Signed-off-by: Nikita Zhandarovich <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Tom Lendacky <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0424a7d commit cbebd68

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/mm/mem_encrypt_identity.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ void __init sme_enable(struct boot_params *bp)
600600
cmdline_ptr = (const char *)((u64)bp->hdr.cmd_line_ptr |
601601
((u64)bp->ext_cmd_line_ptr << 32));
602602

603-
cmdline_find_option(cmdline_ptr, cmdline_arg, buffer, sizeof(buffer));
603+
if (cmdline_find_option(cmdline_ptr, cmdline_arg, buffer, sizeof(buffer)) < 0)
604+
return;
604605

605606
if (!strncmp(buffer, cmdline_on, sizeof(buffer)))
606607
sme_me_mask = me_mask;

0 commit comments

Comments
 (0)