Skip to contentSkip to conversation

x86-crash-make-the-page-that-stores-the-dm-crypt-keys-inaccessible.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message May 21, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: x86/crash: make the page that stores the dm crypt keys inaccessible
has been removed from the -mm tree. Its filename was
x86-crash-make-the-page-that-stores-the-dm-crypt-keys-inaccessible.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Coiby Xu <[email protected]>
Subject: x86/crash: make the page that stores the dm crypt keys inaccessible
Date: Fri, 2 May 2025 09:12:42 +0800

This adds an addition layer of protection for the saved copy of dm crypt key. Trying to access the saved copy will cause page fault.

---

 arch/x86/kernel/machine_kexec_64.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/x86/kernel/machine_kexec_64.c renamed from arch/x86/kernel/machine_kexec_64.c~x86-crash-make-the-page-that-stores-the-dm-crypt-keys-inaccessible +22 -0
@@ -598,13 +598,35 @@ static void kexec_mark_crashkres(bool pr
 	kexec_mark_range(control, crashk_res.end, protect);
 }
 
+/* make the memory storing dm crypt keys in/accessible */
+static void kexec_mark_dm_crypt_keys(bool protect)
+{
+	unsigned long start_paddr, end_paddr;
+	unsigned int nr_pages;
+
+	if (kexec_crash_image->dm_crypt_keys_addr) {
+		start_paddr = kexec_crash_image->dm_crypt_keys_addr;
+		end_paddr = start_paddr + kexec_crash_image->dm_crypt_keys_sz - 1;
+		nr_pages = (PAGE_ALIGN(end_paddr) - PAGE_ALIGN_DOWN(start_paddr))/PAGE_SIZE;
+		if (protect)
+			set_memory_np((unsigned long)phys_to_virt(start_paddr), nr_pages);
+		else
+			__set_memory_prot(
+				(unsigned long)phys_to_virt(start_paddr),
+				nr_pages,
+				__pgprot(_PAGE_PRESENT | _PAGE_NX | _PAGE_RW));
+	}
+}
+
 void arch_kexec_protect_crashkres(void)
 {
 	kexec_mark_crashkres(true);
+	kexec_mark_dm_crypt_keys(true);
 }
 
 void arch_kexec_unprotect_crashkres(void)
 {
+	kexec_mark_dm_crypt_keys(false);
 	kexec_mark_crashkres(false);
 }
 #endif

_

Patches currently in -mm which might be from [email protected] are