Skip to content

Commit 195a1b7

Browse files
Yang Shiwilldeacon
authored andcommitted
arm64: kprobes: call set_memory_rox() for kprobe page
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: 10d5e97 ("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>
1 parent a084c3c commit 195a1b7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

arch/arm64/kernel/probes/kprobes.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define pr_fmt(fmt) "kprobes: " fmt
1212

13+
#include <linux/execmem.h>
1314
#include <linux/extable.h>
1415
#include <linux/kasan.h>
1516
#include <linux/kernel.h>
@@ -41,6 +42,17 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
4142
static void __kprobes
4243
post_kprobe_handler(struct kprobe *, struct kprobe_ctlblk *, struct pt_regs *);
4344

45+
void *alloc_insn_page(void)
46+
{
47+
void *addr;
48+
49+
addr = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
50+
if (!addr)
51+
return NULL;
52+
set_memory_rox((unsigned long)addr, 1);
53+
return addr;
54+
}
55+
4456
static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
4557
{
4658
kprobe_opcode_t *addr = p->ainsn.xol_insn;

0 commit comments

Comments
 (0)