]> git.baikalelectronics.ru Git - kernel.git/commit
x86/mm: Fix use of uninitialized buffer in sme_enable()
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Mon, 6 Mar 2023 16:06:56 +0000 (08:06 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:34:05 +0000 (13:34 +0100)
commit24b07ba4064bda724704e07797ca044033fc8327
treedb7019e602220d3e800c0a9ca5a5dd0aa65dc691
parente56a6fdffcb7cee8cdba3e23183038efa6dfa55b
x86/mm: Fix use of uninitialized buffer in sme_enable()

commit ae54034f633c55dd9fe47d979ae6ebef7f18f192 upstream.

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: a7568920e52f ("x86/mm: Add support to make use of Secure Memory Encryption")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/20230306160656.14844-1-n.zhandarovich@fintech.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/mm/mem_encrypt_identity.c