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

Commit 2bbb3c15 authored by Peng Du's avatar Peng Du Committed by Ruchi Kandoi
Browse files

arm64: kernel: check mode for get_user in undefinstr



get_user() should be called only for user_mode undef instruction.

Change-Id: Ia654783de0cf72abac6847ac9630236f9f0d6ebb
Signed-off-by: default avatarPeng Du <pdu@nvidia.com>
Reviewed-on: http://git-master/r/441348


Reviewed-by: default avatarThomas Cherry <tcherry@nvidia.com>
Reviewed-by: default avatarBo Yan <byan@nvidia.com>
parent f0bb4ad7
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -289,6 +289,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
	/* check for AArch32 breakpoint instructions */
	if (!aarch32_break_handler(regs))
		return;
	if (user_mode(regs)) {
		if (compat_thumb_mode(regs)) {
			if (get_user(instr, (u16 __user *)pc))
				goto die_sig;
@@ -299,10 +300,13 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
				instr <<= 16;
				instr |= instr2;
			}

	} else if ((get_user(instr, (u32 __user *)pc))) {
		} else if (get_user(instr, (u32 __user *)pc)) {
			goto die_sig;
		}
	} else {
		/* kernel mode */
		instr = *((u32 *)pc);
	}

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