Skip to content

Commit 2b2040a

Browse files
wildea01Russell King
authored andcommitted
ARM: 7526/1: traps: send SIGILL if get_user fails on undef handling path
get_user may fail to load from the provided __user address due to an unhandled fault generated by the access. In the case of the undefined instruction trap, this results in failure to load the faulting instruction, in which case we should send SIGILL to the task rather than continue with potentially uninitialised data. Signed-off-by: Will Deacon <will.deacon@arm.com> Cc: stable@vger.kernel.org Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 62194bd commit 2b2040a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎arch/arm/kernel/traps.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,20 +420,23 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
420420
#endif
421421
instr = *(u32 *) pc;
422422
} else if (thumb_mode(regs)) {
423-
get_user(instr, (u16 __user *)pc);
423+
if (get_user(instr, (u16 __user *)pc))
424+
goto die_sig;
424425
if (is_wide_instruction(instr)) {
425426
unsigned int instr2;
426-
get_user(instr2, (u16 __user *)pc+1);
427+
if (get_user(instr2, (u16 __user *)pc+1))
428+
goto die_sig;
427429
instr <<= 16;
428430
instr |= instr2;
429431
}
430-
} else {
431-
get_user(instr, (u32 __user *)pc);
432+
} else if (get_user(instr, (u32 __user *)pc)) {
433+
goto die_sig;
432434
}
433435

434436
if (call_undef_hook(regs, instr) == 0)
435437
return;
436438

439+
die_sig:
437440
#ifdef CONFIG_DEBUG_USER
438441
if (user_debug & UDBG_UNDEFINED) {
439442
printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n",

0 commit comments

Comments
 (0)