Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b2040af authored by Will Deacon's avatar Will Deacon Committed by Russell King
Browse files

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: default avatarWill Deacon <will.deacon@arm.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 62194bda
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -420,20 +420,23 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
#endif
#endif
			instr = *(u32 *) pc;
			instr = *(u32 *) pc;
	} else if (thumb_mode(regs)) {
	} else if (thumb_mode(regs)) {
		get_user(instr, (u16 __user *)pc);
		if (get_user(instr, (u16 __user *)pc))
			goto die_sig;
		if (is_wide_instruction(instr)) {
		if (is_wide_instruction(instr)) {
			unsigned int instr2;
			unsigned int instr2;
			get_user(instr2, (u16 __user *)pc+1);
			if (get_user(instr2, (u16 __user *)pc+1))
				goto die_sig;
			instr <<= 16;
			instr <<= 16;
			instr |= instr2;
			instr |= instr2;
		}
		}
	} else {
	} else if (get_user(instr, (u32 __user *)pc)) {
		get_user(instr, (u32 __user *)pc);
		goto die_sig;
	}
	}


	if (call_undef_hook(regs, instr) == 0)
	if (call_undef_hook(regs, instr) == 0)
		return;
		return;


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