[tip: x86/boot] x86/kexec: Mark relocate_kernel page as ROX instead of RWX
From: tip-bot2 for David Woodhouse
Date: Fri Dec 06 2024 - 05:19:04 EST
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: 5a82223e0743fb36bcb99657772513739d1a9936
Gitweb: https://git.kernel.org/tip/5a82223e0743fb36bcb99657772513739d1a9936
Author: David Woodhouse <dwmw@xxxxxxxxxxxx>
AuthorDate: Thu, 05 Dec 2024 15:05:19
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Fri, 06 Dec 2024 10:42:01 +01:00
x86/kexec: Mark relocate_kernel page as ROX instead of RWX
All writes to the page now happen before it gets marked as executable
(or after it's already switched to the identmap page tables where it's
OK to be RWX).
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Baoquan He <bhe@xxxxxxxxxx>
Cc: Vivek Goyal <vgoyal@xxxxxxxxxx>
Cc: Dave Young <dyoung@xxxxxxxxxx>
Cc: Eric Biederman <ebiederm@xxxxxxxxxxxx>
Cc: Ard Biesheuvel <ardb@xxxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20241205153343.3275139-14-dwmw2@xxxxxxxxxxxxx
---
arch/x86/kernel/machine_kexec_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index c9fd60f..9232ad1 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -323,7 +323,7 @@ int machine_kexec_prepare(struct kimage *image)
__memcpy(control_page, __relocate_kernel_start, reloc_end - reloc_start);
- set_memory_x((unsigned long)control_page, 1);
+ set_memory_rox((unsigned long)control_page, 1);
return 0;
}
@@ -333,6 +333,7 @@ void machine_kexec_cleanup(struct kimage *image)
void *control_page = page_address(image->control_code_page);
set_memory_nx((unsigned long)control_page, 1);
+ set_memory_rw((unsigned long)control_page, 1);
free_transition_pgtable(image);
}