Commit 6cf5d4af authored by Luc Van Oostenryck's avatar Luc Van Oostenryck Committed by Will Deacon

arm64: fix endianness annotation in call_undef_hook()

Here we're reading thumb or ARM instructions, which are always
stored in memory in little-endian order. These values are thus
correctly converted to native order but the intermediate value
should be annotated as for little-endian values.

Fix this by declaring the intermediate var as __le32 or __le16.
Signed-off-by: default avatarLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent a5018b0e
...@@ -344,22 +344,24 @@ static int call_undef_hook(struct pt_regs *regs) ...@@ -344,22 +344,24 @@ static int call_undef_hook(struct pt_regs *regs)
if (compat_thumb_mode(regs)) { if (compat_thumb_mode(regs)) {
/* 16-bit Thumb instruction */ /* 16-bit Thumb instruction */
if (get_user(instr, (u16 __user *)pc)) __le16 instr_le;
if (get_user(instr_le, (__le16 __user *)pc))
goto exit; goto exit;
instr = le16_to_cpu(instr); instr = le16_to_cpu(instr_le);
if (aarch32_insn_is_wide(instr)) { if (aarch32_insn_is_wide(instr)) {
u32 instr2; u32 instr2;
if (get_user(instr2, (u16 __user *)(pc + 2))) if (get_user(instr_le, (__le16 __user *)(pc + 2)))
goto exit; goto exit;
instr2 = le16_to_cpu(instr2); instr2 = le16_to_cpu(instr_le);
instr = (instr << 16) | instr2; instr = (instr << 16) | instr2;
} }
} else { } else {
/* 32-bit ARM instruction */ /* 32-bit ARM instruction */
if (get_user(instr, (u32 __user *)pc)) __le32 instr_le;
if (get_user(instr_le, (__le32 __user *)pc))
goto exit; goto exit;
instr = le32_to_cpu(instr); instr = le32_to_cpu(instr_le);
} }
raw_spin_lock_irqsave(&undef_lock, flags); raw_spin_lock_irqsave(&undef_lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment