diff options
author | Kirill A. Shutemov <kirill@shutemov.name> | 2021-11-30 21:49:30 +0300 |
---|---|---|
committer | Dave Hansen <dave.hansen@linux.intel.com> | 2021-11-30 14:52:26 -0800 |
commit | 23ef731e4365196bfc186358eb4f6265d60ab352 (patch) | |
tree | 90afa7b97341ebf4fd380d876022d3cc9328acdb /arch/x86/lib/insn-eval.c | |
parent | d58071a8a76d779eedab38033ae4c821c30295a5 (diff) | |
download | lwn-23ef731e4365196bfc186358eb4f6265d60ab352.tar.gz lwn-23ef731e4365196bfc186358eb4f6265d60ab352.zip |
x86/insn-eval: Handle insn_get_opcode() failure
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 <kirill.shutemov@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Joerg Roedel <jroedel@suse.de>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lkml.kernel.org/r/20211130184933.31005-2-kirill.shutemov@linux.intel.com
Diffstat (limited to 'arch/x86/lib/insn-eval.c')
-rw-r--r-- | arch/x86/lib/insn-eval.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c index eb3ccffb9b9d..1c51e8a415e2 100644 --- a/arch/x86/lib/insn-eval.c +++ b/arch/x86/lib/insn-eval.c @@ -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; @@ -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); |