Skip to contentSkip to conversation

x86-kprobes-enable-execmem_rox_cache-for-kprobes-allocations.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Aug 2, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: x86/kprobes: enable EXECMEM_ROX_CACHE for kprobes allocations
has been removed from the -mm tree. Its filename was
x86-kprobes-enable-execmem_rox_cache-for-kprobes-allocations.patch

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

------------------------------------------------------
From: "Mike Rapoport (Microsoft)" <[email protected]>
Subject: x86/kprobes: enable EXECMEM_ROX_CACHE for kprobes allocations
Date: Sun, 13 Jul 2025 10:17:29 +0300

x86::alloc_insn_page() always allocates ROX memory.

Instead of overriding this method, add EXECMEM_KPROBES entry in execmem_info with pgprot set to PAGE_KERNEL_ROX and use ROX cache when configuration and CPU features allow it.

---

 arch/x86/kernel/kprobes/core.c |   18 ------------------
 arch/x86/mm/init.c             |    9 ++++++++-
 2 files changed, 8 insertions(+), 19 deletions(-)
arch/x86/kernel/kprobes/core.c renamed from arch/x86/kernel/kprobes/core.c~x86-kprobes-enable-execmem_rox_cache-for-kprobes-allocations +0 -18
@@ -481,24 +481,6 @@ static int prepare_singlestep(kprobe_opc
 	return len;
 }
 
-/* Make page to RO mode when allocate it */
-void *alloc_insn_page(void)
-{
-	void *page;
-
-	page = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
-	if (!page)
-		return NULL;
-
-	/*
-	 * TODO: Once additional kernel code protection mechanisms are set, ensure
-	 * that the page was not maliciously altered and it is still zeroed.
-	 */
-	set_memory_rox((unsigned long)page, 1);
-
-	return page;
-}
-
 /* Kprobe x86 instruction emulation - only regs->ip or IF flag modifiers */
 
 static void kprobe_emulate_ifmodifiers(struct kprobe *p, struct pt_regs *regs)
arch/x86/mm/init.c renamed from arch/x86/mm/init.c~x86-kprobes-enable-execmem_rox_cache-for-kprobes-allocations +8 -1
@@ -1098,7 +1098,14 @@ struct execmem_info __init *execmem_arch
 				.pgprot	= pgprot,
 				.alignment = MODULE_ALIGN,
 			},
-			[EXECMEM_KPROBES ... EXECMEM_BPF] = {
+			[EXECMEM_KPROBES] = {
+				.flags	= flags,
+				.start	= start,
+				.end	= MODULES_END,
+				.pgprot	= PAGE_KERNEL_ROX,
+				.alignment = MODULE_ALIGN,
+			},
+			[EXECMEM_FTRACE ... EXECMEM_BPF] = {
 				.flags	= EXECMEM_KASAN_SHADOW,
 				.start	= start,
 				.end	= MODULES_END,

_

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

kho-add-test-for-kexec-handover.patch
kho-add-test-for-kexec-handover-fix.patch