Skip to contentSkip to conversation

kexec_file-fix-incorrect-temp_start-value-in-locate_mem_hole_top_down.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Dec 29, 2023

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: kexec_file: fix incorrect temp_start value in locate_mem_hole_top_down()
has been removed from the -mm tree. Its filename was
kexec_file-fix-incorrect-temp_start-value-in-locate_mem_hole_top_down.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: Yuntao Wang <[email protected]>
Subject: kexec_file: fix incorrect temp_start value in locate_mem_hole_top_down()
Date: Sun, 17 Dec 2023 11:35:27 +0800

temp_end represents the address of the last available byte. Therefore, the starting address of the memory segment with temp_end as its last available byte and a size of kbuf->memsz, that is, the value of temp_start, should be temp_end - kbuf->memsz + 1 instead of temp_end - kbuf->memsz.

Additionally, use the ALIGN_DOWN macro instead of open-coding it directly in locate_mem_hole_top_down() to improve code readability.

Cc Borislav Petkov (AMD) <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Thomas Gleixner <[email protected]>

---

 kernel/kexec_file.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kexec_file.c renamed from kernel/kexec_file.c~kexec_file-fix-incorrect-temp_start-value-in-locate_mem_hole_top_down +2 -2
@@ -434,11 +434,11 @@ static int locate_mem_hole_top_down(unsi
 	unsigned long temp_start, temp_end;
 
 	temp_end = min(end, kbuf->buf_max);
-	temp_start = temp_end - kbuf->memsz;
+	temp_start = temp_end - kbuf->memsz + 1;
 
 	do {
 		/* align down start */
-		temp_start = temp_start & (~(kbuf->buf_align - 1));
+		temp_start = ALIGN_DOWN(temp_start, kbuf->buf_align);
 
 		if (temp_start < start || temp_start < kbuf->buf_min)
 			return 0;

_

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

x86-crash-remove-the-unused-image-parameter-from-prepare_elf_headers.patch x86-crash-use-sz_1m-macro-instead-of-hardcoded-value.patch crash_core-fix-and-simplify-the-logic-of-crash_exclude_mem_range.patch x86-crash-fix-potential-cmem-ranges-array-overflow.patch crash_core-optimize-crash_exclude_mem_range.patch