FAILED: patch "[PATCH] x86/mm: Fix use of uninitialized buffer in sme_enable()" failed to apply to 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@xxxxxxxxxxxxxxx>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.14.y
git checkout FETCH_HEAD
git cherry-pick -x cbebd68f59f03633469f3ecf9bea99cd6cce3854
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@xxxxxxxxxxxxxxx>' --in-reply-to '167931308586149@xxxxxxxxx' --subject-prefix 'PATCH 4.14.y' HEAD^..

Possible dependencies:

cbebd68f59f0 ("x86/mm: Fix use of uninitialized buffer in sme_enable()")
1cd9c22fee3a ("x86/mm/encrypt: Move page table helpers into separate translation unit")
91cfc88c66bf ("x86: Use __nostackprotect for sme_encrypt_kernel")
107cd2532181 ("x86/mm: Encrypt the initrd earlier for BSP microcode update")
cc5f01e28d6c ("x86/mm: Prepare sme_encrypt_kernel() for PAGE aligned encryption")
2b5d00b6c2cd ("x86/mm: Centralize PMD flags in sme_encrypt_kernel()")
bacf6b499e11 ("x86/mm: Use a struct to reduce parameters for SME PGD mapping")
1303880179e6 ("x86/mm: Clean up register saving in the __enc_copy() assembly code")
dfaaec9033b8 ("x86: Add support for changing memory encryption attribute in early boot")
1958b5fc4010 ("x86/boot: Add early boot support when running with SEV active")
d7b417fa08d1 ("x86/mm: Add DMA support for SEV memory encryption")
682af54399b6 ("x86/mm: Don't attempt to encrypt initrd under SEV")
d8aa7eea78a1 ("x86/mm: Add Secure Encrypted Virtualization (SEV) support")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From cbebd68f59f03633469f3ecf9bea99cd6cce3854 Mon Sep 17 00:00:00 2001
From: Nikita Zhandarovich <n.zhandarovich@xxxxxxxxxx>
Date: Mon, 6 Mar 2023 08:06:56 -0800
Subject: [PATCH] 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: aca20d546214 ("x86/mm: Add support to make use of Secure Memory Encryption")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@xxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Acked-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
Cc: <stable@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20230306160656.14844-1-n.zhandarovich@xxxxxxxxxx

diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c
index 88cccd65029d..c6efcf559d88 100644
--- a/arch/x86/mm/mem_encrypt_identity.c
+++ b/arch/x86/mm/mem_encrypt_identity.c
@@ -600,7 +600,8 @@ void __init sme_enable(struct boot_params *bp)
 	cmdline_ptr = (const char *)((u64)bp->hdr.cmd_line_ptr |
 				     ((u64)bp->ext_cmd_line_ptr << 32));
 
-	cmdline_find_option(cmdline_ptr, cmdline_arg, buffer, sizeof(buffer));
+	if (cmdline_find_option(cmdline_ptr, cmdline_arg, buffer, sizeof(buffer)) < 0)
+		return;
 
 	if (!strncmp(buffer, cmdline_on, sizeof(buffer)))
 		sme_me_mask = me_mask;




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux