summaryrefslogtreecommitdiff
path: root/arch/arm64
diff options
context:
space:
mode:
authorYang Shi <yang@os.amperecomputing.com>2025-09-18 09:23:49 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-19 16:33:44 +0200
commit4e7eec38e27d6e856fd9e9a5ce16317903c34822 (patch)
treefa1e70ea1b1655f8bf1cd76928f78e9e7b56c5e3 /arch/arm64
parent454128d96cf5af86c023ee8cca246668f70679a4 (diff)
downloadlinux-4e7eec38e27d6e856fd9e9a5ce16317903c34822.tar.gz
linux-4e7eec38e27d6e856fd9e9a5ce16317903c34822.tar.bz2
linux-4e7eec38e27d6e856fd9e9a5ce16317903c34822.zip
arm64: kprobes: call set_memory_rox() for kprobe page
commit 195a1b7d8388c0ec2969a39324feb8bebf9bb907 upstream. 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> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/kernel/probes/kprobes.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 4268678d0e86..6e397d8dcd4c 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.api.insn;