Commit 0ec364c0 authored by Yang Shi's avatar Yang Shi Committed by Will Deacon
Browse files

arm64: kprobes: check the return value of set_memory_rox()



Since commit a166563e ("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: 195a1b7d ("arm64: kprobes: call set_memory_rox() for kprobe page")
Reviewed-by: default avatarRyan Roberts <ryan.roberts@arm.com>
Reviewed-by: default avatarDev Jain <dev.jain@arm.com>
Signed-off-by: default avatarYang Shi <yang@os.amperecomputing.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 7991fda6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -49,7 +49,10 @@ void *alloc_insn_page(void)
	addr = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
	if (!addr)
		return NULL;
	set_memory_rox((unsigned long)addr, 1);
	if (set_memory_rox((unsigned long)addr, 1)) {
		execmem_free(addr);
		return NULL;
	}
	return addr;
}