Skip to contentSkip to conversation

kho-fix-unpreservation-of-higher-order-vmalloc-preservations.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Nov 10, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: kho: fix unpreservation of higher-order vmalloc preservations
has been removed from the -mm tree. Its filename was
kho-fix-unpreservation-of-higher-order-vmalloc-preservations.patch

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

------------------------------------------------------
From: Pratyush Yadav <[email protected]>
Subject: kho: fix unpreservation of higher-order vmalloc preservations
Date: Mon, 3 Nov 2025 19:02:31 +0100

kho_vmalloc_unpreserve_chunk() calls __kho_unpreserve() with end_pfn as pfn + 1. This happens to work for 0-order pages, but leaks higher order pages.

For example, say order 2 pages back the allocation. During preservation, they get preserved in the order 2 bitmaps, but kho_vmalloc_unpreserve_chunk() would try to unpreserve them from the order 0 bitmaps, which should not have these bits set anyway, leaving the order 2 bitmaps untouched. This results in the pages being carried over to the next kernel. Nothing will free those pages in the next boot, leaking them.

Fix this by taking the order into account when calculating the end PFN for __kho_unpreserve().

Fixes a667300bd53f ("kho: add support for preserving vmalloc allocations")
Cc Alexander Graf <[email protected]>
Cc Baoquan He <[email protected]>
Cc Pasha Tatashin <[email protected]>

---

 kernel/kexec_handover.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/kexec_handover.c renamed from kernel/kexec_handover.c~kho-fix-unpreservation-of-higher-order-vmalloc-preservations +4 -3
@@ -882,7 +882,8 @@ err_free:
 	return NULL;
 }
 
-static void kho_vmalloc_unpreserve_chunk(struct kho_vmalloc_chunk *chunk)
+static void kho_vmalloc_unpreserve_chunk(struct kho_vmalloc_chunk *chunk,
+					 unsigned short order)
 {
 	struct kho_mem_track *track = &kho_out.ser.track;
 	unsigned long pfn = PHYS_PFN(virt_to_phys(chunk));
@@ -891,7 +892,7 @@ static void kho_vmalloc_unpreserve_chunk
 
 	for (int i = 0; i < ARRAY_SIZE(chunk->phys) && chunk->phys[i]; i++) {
 		pfn = PHYS_PFN(chunk->phys[i]);
-		__kho_unpreserve(track, pfn, pfn + 1);
+		__kho_unpreserve(track, pfn, pfn + (1 << order));
 	}
 }
 
@@ -902,7 +903,7 @@ static void kho_vmalloc_free_chunks(stru
 	while (chunk) {
 		struct kho_vmalloc_chunk *tmp = chunk;
 
-		kho_vmalloc_unpreserve_chunk(chunk);
+		kho_vmalloc_unpreserve_chunk(chunk, kho_vmalloc->order);
 
 		chunk = KHOSER_LOAD_PTR(chunk->hdr.next);
 		free_page((unsigned long)tmp);

_

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

maintainers-add-myself-as-a-reviewer-for-kho.patch liveupdate-luo_file-add-private-argument-to-store-runtime-state.patch