public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [v2 PATCH] arm64: kprobes: call set_memory_rox() for kprobe page
@ 2025-09-18 16:23 Yang Shi
  2025-09-18 17:26 ` Will Deacon
  0 siblings, 1 reply; 6+ messages in thread
From: Yang Shi @ 2025-09-18 16:23 UTC (permalink / raw)
  To: catalin.marinas, will, ryan.roberts
  Cc: yang, linux-arm-kernel, linux-kernel, stable

The kprobe page is allocated by execmem allocator with ROX permission.
It needs to call set_memory_rox() to set proper permission for the
direct map too. It was missed.

Fixes: 10d5e97c1bf8 ("arm64: use PAGE_KERNEL_ROX directly in alloc_insn_page")
Cc: <stable@vger.kernel.org>
Signed-off-by: Yang Shi <yang@os.amperecomputing.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
---
v2: Separated the patch from BBML2 series since it is an orthogonal bug
    fix per Ryan.
    Fixed the variable name nit per Catalin.
    Collected R-bs from Catalin.

 arch/arm64/kernel/probes/kprobes.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 0c5d408afd95..8ab6104a4883 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -10,6 +10,7 @@
 
 #define pr_fmt(fmt) "kprobes: " fmt
 
+#include <linux/execmem.h>
 #include <linux/extable.h>
 #include <linux/kasan.h>
 #include <linux/kernel.h>
@@ -41,6 +42,17 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 static void __kprobes
 post_kprobe_handler(struct kprobe *, struct kprobe_ctlblk *, struct pt_regs *);
 
+void *alloc_insn_page(void)
+{
+	void *addr;
+
+	addr = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
+	if (!addr)
+		return NULL;
+	set_memory_rox((unsigned long)addr, 1);
+	return addr;
+}
+
 static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
 {
 	kprobe_opcode_t *addr = p->ainsn.xol_insn;
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-23 17:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 16:23 [v2 PATCH] arm64: kprobes: call set_memory_rox() for kprobe page Yang Shi
2025-09-18 17:26 ` Will Deacon
2025-09-18 17:33   ` Yang Shi
2025-09-21  7:36     ` Mike Rapoport
2025-09-23 17:43       ` Yang Shi
2025-09-19  4:01   ` Dev Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox