lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211018164941.3nqq73pupep3cejz@box.shutemov.name>
Date:   Mon, 18 Oct 2021 19:49:41 +0300
From:   "Kirill A. Shutemov" <kirill@...temov.name>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Tom Lendacky <thomas.lendacky@....com>,
        Joerg Roedel <jroedel@...e.de>,
        Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Sean Christopherson <seanjc@...gle.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Tony Luck <tony.luck@...el.com>
Subject: Re: [PATCH 2/3] x86/insn-eval: Introduce insn_decode_mmio()

On Mon, Oct 18, 2021 at 05:53:49PM +0200, Peter Zijlstra wrote:
> On Mon, Oct 18, 2021 at 06:33:32PM +0300, Kirill A. Shutemov wrote:
> 
> > diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c
> > index fbaa3fa24bde..2ab29d8d6731 100644
> > --- a/arch/x86/lib/insn-eval.c
> > +++ b/arch/x86/lib/insn-eval.c
> > @@ -1559,3 +1559,85 @@ bool insn_decode_from_regs(struct insn *insn, struct pt_regs *regs,
> >  
> >  	return true;
> >  }
> > +
> > +/**
> > + * insn_decode_mmio() - Decode a MMIO instruction
> > + * @insn:	Structure to store decoded instruction
> > + * @bytes:	Returns size of memory operand
> > + *
> > + * Decodes instruction that used for Memory-mapped I/O.
> > + *
> > + * Returns:
> > + *
> > + * Type of the instruction. Size of the memory operand is stored in
> > + * @bytes. If decode failed, MMIO_DECODE_FAILED returned.
> > + */
> > +enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes)
> > +{
> > +	int type = MMIO_DECODE_FAILED;
> > +
> > +	*bytes = 0;
> > +
> > +	insn_get_opcode(insn);
> 
> insn_get_opcode() can fail. Either you assume it's already called and
> don't call it, or you can't assume anything and get to do error
> handling.

Fair enough. I will return MMIO_DECODE_FAILED if insn_get_opcode() fails.

BTW, looks like is_string_insn() suffers from the same issue. Not sure how
to fix it though.

-- 
 Kirill A. Shutemov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ