summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Shi <yang@os.amperecomputing.com>2025-10-16 15:57:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-19 16:30:59 +0200
commit7f4f031e66ad978f180506f6d2ba35bcb2bab3be (patch)
tree889baddf9fd51c2ae1adb7c25ccf1712397f9bfd
parentca603d157694a49b2e3aa6579f15faef75e44c93 (diff)
downloadlinux-7f4f031e66ad978f180506f6d2ba35bcb2bab3be.tar.gz
linux-7f4f031e66ad978f180506f6d2ba35bcb2bab3be.tar.bz2
linux-7f4f031e66ad978f180506f6d2ba35bcb2bab3be.zip
arm64: kprobes: call set_memory_rox() for kprobe page
[ Upstream commit 195a1b7d8388c0ec2969a39324feb8bebf9bb907 ] 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> [ kept existing __vmalloc_node_range() instead of upstream's execmem_alloc() ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/arm64/kernel/probes/kprobes.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 70b91a8c6bb3..c0942cce3b68 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -131,9 +131,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
void *alloc_insn_page(void)
{
- return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
+ void *addr;
+
+ addr = __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
GFP_KERNEL, PAGE_KERNEL_ROX, VM_FLUSH_RESET_PERMS,
NUMA_NO_NODE, __builtin_return_address(0));
+ if (!addr)
+ return NULL;
+ set_memory_rox((unsigned long)addr, 1);
+ return addr;
}
/* arm kprobe: install breakpoint in text */