Skip to content

Commit

Permalink
x86/insn-eval: Handle insn_get_opcode() failure
Browse files Browse the repository at this point in the history
is_string_insn() calls insn_get_opcode() that can fail, but does not
handle the failure.

is_string_insn() interface does not allow to communicate an error to the
caller.

Push insn_get_opcode() to the only non-static user of is_string_insn()
and fail it early if insn_get_opcode() fails.

[ dhansen: fix tabs-versus-spaces breakage ]

Signed-off-by: Kirill A. Shutemov <[email protected]>
Signed-off-by: Dave Hansen <[email protected]>
Tested-by: Joerg Roedel <[email protected]>
Acked-by: Tom Lendacky <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
kiryl authored and hansendc committed Nov 30, 2021
1 parent d58071a commit 23ef731
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/lib/insn-eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ enum reg_type {
*/
static bool is_string_insn(struct insn *insn)
{
insn_get_opcode(insn);

/* All string instructions have a 1-byte opcode. */
if (insn->opcode.nbytes != 1)
return false;
Expand Down Expand Up @@ -1405,6 +1403,9 @@ void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)
if (!insn || !regs)
return (void __user *)-1L;

if (insn_get_opcode(insn))
return (void __user *)-1L;

switch (insn->addr_bytes) {
case 2:
return get_addr_ref_16(insn, regs);
Expand Down

0 comments on commit 23ef731

Please sign in to comment.