x86/traps: Convert to insn_decode()

Simplify code, no functional changes.

Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210304174237.31945-15-bp@alien8.de
This commit is contained in:
Borislav Petkov 2020-11-16 18:38:45 +01:00
parent 5e32c64bb6
commit 0be7f42d6f
1 changed files with 4 additions and 3 deletions

View File

@ -498,14 +498,15 @@ static enum kernel_gp_hint get_kernel_gp_address(struct pt_regs *regs,
{ {
u8 insn_buf[MAX_INSN_SIZE]; u8 insn_buf[MAX_INSN_SIZE];
struct insn insn; struct insn insn;
int ret;
if (copy_from_kernel_nofault(insn_buf, (void *)regs->ip, if (copy_from_kernel_nofault(insn_buf, (void *)regs->ip,
MAX_INSN_SIZE)) MAX_INSN_SIZE))
return GP_NO_HINT; return GP_NO_HINT;
kernel_insn_init(&insn, insn_buf, MAX_INSN_SIZE); ret = insn_decode(&insn, insn_buf, MAX_INSN_SIZE, INSN_MODE_KERN);
insn_get_modrm(&insn); if (ret < 0)
insn_get_sib(&insn); return GP_NO_HINT;
*addr = (unsigned long)insn_get_addr_ref(&insn, regs); *addr = (unsigned long)insn_get_addr_ref(&insn, regs);
if (*addr == -1UL) if (*addr == -1UL)