Skip to content

Commit 0ec364c

Browse files
Yang Shiwilldeacon
authored andcommitted
arm64: kprobes: check the return value of set_memory_rox()
Since commit a166563 ("arm64: mm: support large block mapping when rodata=full"), __change_memory_common has more chance to fail due to memory allocation failure when splitting page table. So check the return value of set_memory_rox(), then bail out if it fails otherwise we may have RW memory mapping for kprobes insn page. Fixes: 195a1b7 ("arm64: kprobes: call set_memory_rox() for kprobe page") Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Reviewed-by: Dev Jain <dev.jain@arm.com> Signed-off-by: Yang Shi <yang@os.amperecomputing.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 7991fda commit 0ec364c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

arch/arm64/kernel/probes/kprobes.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ void *alloc_insn_page(void)
4949
addr = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
5050
if (!addr)
5151
return NULL;
52-
set_memory_rox((unsigned long)addr, 1);
52+
if (set_memory_rox((unsigned long)addr, 1)) {
53+
execmem_free(addr);
54+
return NULL;
55+
}
5356
return addr;
5457
}
5558

0 commit comments

Comments
 (0)