[RFC PATCH v0 12/19] x86/traps: Convert to insn_decode()

Borislav Petkov
2020-11-24T10:20:25Z

Simplify code, no functional changes.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/kernel/traps.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index e1b78829d909..4a06f79aaeeb 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -493,14 +493,15 @@ static enum kernel_gp_hint get_kernel_gp_address(struct pt_regs *regs,
{
u8 insn_buf[MAX_INSN_SIZE];
struct insn insn;
+ int ret;

if (copy_from_kernel_nofault(insn_buf, (void *)regs->ip,
MAX_INSN_SIZE))
return GP_NO_HINT;

- kernel_insn_init(&insn, insn_buf, MAX_INSN_SIZE);
- insn_get_modrm(&insn);
- insn_get_sib(&insn);
+ ret = insn_decode(&insn, insn_buf, MAX_INSN_SIZE, INSN_MODE_KERN);
+ if (ret < 0)
+ return GP_NO_HINT;

*addr = (unsigned long)insn_get_addr_ref(&insn, regs);
if (*addr == -1UL)
--
2.21.0