Skip to content

Commit 9339693

Browse files
amitdanielkachhapwilldeacon
authored andcommitted
arm64: kprobe: add checks for ARMv8.3-PAuth combined instructions
Currently the ARMv8.3-PAuth combined branch instructions (braa, retaa etc.) are not simulated for out-of-line execution with a handler. Hence the uprobe of such instructions leads to kernel warnings in a loop as they are not explicitly checked and fall into INSN_GOOD categories. Other combined instructions like LDRAA and LDRBB can be probed. The issue of the combined branch instructions is fixed by adding group definitions of all such instructions and rejecting their probes. The instruction groups added are br_auth(braa, brab, braaz and brabz), blr_auth(blraa, blrab, blraaz and blrabz), ret_auth(retaa and retab) and eret_auth(eretaa and eretab). Warning log: WARNING: CPU: 0 PID: 156 at arch/arm64/kernel/probes/uprobes.c:182 uprobe_single_step_handler+0x34/0x50 Modules linked in: CPU: 0 PID: 156 Comm: func Not tainted 5.9.0-rc3 #188 Hardware name: Foundation-v8A (DT) pstate: 804003c9 (Nzcv DAIF +PAN -UAO BTYPE=--) pc : uprobe_single_step_handler+0x34/0x50 lr : single_step_handler+0x70/0xf8 sp : ffff800012af3e30 x29: ffff800012af3e30 x28: ffff000878723b00 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 x23: 0000000060001000 x22: 00000000cb000022 x21: ffff800012065ce8 x20: ffff800012af3ec0 x19: ffff800012068d50 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: 0000000000000000 x9 : ffff800010085c90 x8 : 0000000000000000 x7 : 0000000000000000 x6 : ffff80001205a9c8 x5 : ffff80001205a000 x4 : ffff80001233db80 x3 : ffff8000100a7a60 x2 : 0020000000000003 x1 : 0000fffffffff008 x0 : ffff800012af3ec0 Call trace: uprobe_single_step_handler+0x34/0x50 single_step_handler+0x70/0xf8 do_debug_exception+0xb8/0x130 el0_sync_handler+0x138/0x1b8 el0_sync+0x158/0x180 Fixes: 74afda4 ("arm64: compile the kernel with ptrauth return address signing") Fixes: 04ca320 ("arm64: enable pointer authentication") Signed-off-by: Amit Daniel Kachhap <[email protected]> Reviewed-by: Dave Martin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent f75aef3 commit 9339693

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

arch/arm64/include/asm/insn.h

+4
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,13 @@ __AARCH64_INSN_FUNCS(brk, 0xFFE0001F, 0xD4200000)
359359
__AARCH64_INSN_FUNCS(exception, 0xFF000000, 0xD4000000)
360360
__AARCH64_INSN_FUNCS(hint, 0xFFFFF01F, 0xD503201F)
361361
__AARCH64_INSN_FUNCS(br, 0xFFFFFC1F, 0xD61F0000)
362+
__AARCH64_INSN_FUNCS(br_auth, 0xFEFFF800, 0xD61F0800)
362363
__AARCH64_INSN_FUNCS(blr, 0xFFFFFC1F, 0xD63F0000)
364+
__AARCH64_INSN_FUNCS(blr_auth, 0xFEFFF800, 0xD63F0800)
363365
__AARCH64_INSN_FUNCS(ret, 0xFFFFFC1F, 0xD65F0000)
366+
__AARCH64_INSN_FUNCS(ret_auth, 0xFFFFFBFF, 0xD65F0BFF)
364367
__AARCH64_INSN_FUNCS(eret, 0xFFFFFFFF, 0xD69F03E0)
368+
__AARCH64_INSN_FUNCS(eret_auth, 0xFFFFFBFF, 0xD69F0BFF)
365369
__AARCH64_INSN_FUNCS(mrs, 0xFFF00000, 0xD5300000)
366370
__AARCH64_INSN_FUNCS(msr_imm, 0xFFF8F01F, 0xD500401F)
367371
__AARCH64_INSN_FUNCS(msr_reg, 0xFFF00000, 0xD5100000)

arch/arm64/kernel/insn.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool __kprobes aarch64_insn_uses_literal(u32 insn)
176176

177177
bool __kprobes aarch64_insn_is_branch(u32 insn)
178178
{
179-
/* b, bl, cb*, tb*, b.cond, br, blr */
179+
/* b, bl, cb*, tb*, ret*, b.cond, br*, blr* */
180180

181181
return aarch64_insn_is_b(insn) ||
182182
aarch64_insn_is_bl(insn) ||
@@ -185,8 +185,11 @@ bool __kprobes aarch64_insn_is_branch(u32 insn)
185185
aarch64_insn_is_tbz(insn) ||
186186
aarch64_insn_is_tbnz(insn) ||
187187
aarch64_insn_is_ret(insn) ||
188+
aarch64_insn_is_ret_auth(insn) ||
188189
aarch64_insn_is_br(insn) ||
190+
aarch64_insn_is_br_auth(insn) ||
189191
aarch64_insn_is_blr(insn) ||
192+
aarch64_insn_is_blr_auth(insn) ||
190193
aarch64_insn_is_bcond(insn);
191194
}
192195

arch/arm64/kernel/probes/decode-insn.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
2929
aarch64_insn_is_msr_imm(insn) ||
3030
aarch64_insn_is_msr_reg(insn) ||
3131
aarch64_insn_is_exception(insn) ||
32-
aarch64_insn_is_eret(insn))
32+
aarch64_insn_is_eret(insn) ||
33+
aarch64_insn_is_eret_auth(insn))
3334
return false;
3435

3536
/*

0 commit comments

Comments
 (0)