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] [day] [month] [year] [list]
Message-ID: <1485910893.41148.80.camel@ranerica-desktop>
Date:   Tue, 31 Jan 2017 17:01:33 -0800
From:   Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
To:     Masami Hiramatsu <mhiramat@...nel.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andy Lutomirski <luto@...nel.org>,
        Borislav Petkov <bp@...e.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Brian Gerst <brgerst@...il.com>,
        Chris Metcalf <cmetcalf@...lanox.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Liang Z Li <liang.z.li@...el.com>,
        Huang Rui <ray.huang@....com>, Jiri Slaby <jslaby@...e.cz>,
        Jonathan Corbet <corbet@....net>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Paul Gortmaker <paul.gortmaker@...driver.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Chen Yucong <slaoub@...il.com>,
        Alexandre Julliard <julliard@...ehq.org>,
        Fenghua Yu <fenghua.yu@...el.com>, Stas Sergeev <stsp@...t.ru>,
        "Ravi V. Shankar" <ravi.v.shankar@...el.com>,
        Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org,
        x86@...nel.org, linux-msdos@...r.kernel.org, wine-devel@...ehq.org,
        Adam Buchbinder <adam.buchbinder@...il.com>,
        Colin Ian King <colin.king@...onical.com>,
        Lorenzo Stoakes <lstoakes@...il.com>,
        Qiaowei Ren <qiaowei.ren@...el.com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Kees Cook <keescook@...omium.org>,
        Thomas Garnier <thgarnie@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [v3 PATCH 04/10] x86/insn-kernel: Add a function to obtain
 register offset in ModRM

On Fri, 2017-01-27 at 16:53 +0900, Masami Hiramatsu wrote:
> On Wed, 25 Jan 2017 22:07:16 -0800
> Ricardo Neri <ricardo.neri-calderon@...ux.intel.com> wrote:
> 
> > Hi Masami,
> > 
> > On Thu, 2017-01-26 at 11:11 +0900, Masami Hiramatsu wrote:
> > > On Wed, 25 Jan 2017 12:23:47 -0800
> > > Ricardo Neri <ricardo.neri-calderon@...ux.intel.com> wrote:
> > > 
> > > > The function insn_get_reg_offset requires a type to indicate whether
> > > > the returned offset is that given by by the ModRM or the SIB byte.
> > > > Callers of this function would need the definition of the type struct.
> > > > This is not needed. Instead, auxiliary functions can be defined for
> > > > this purpose.
> > > > 
> > > > When the operand is a register, the emulation code for User-Mode
> > > > Instruction Prevention needs to know the offset of the register indicated
> > > > in the r/m part of the ModRM byte. Thus, start by adding an auxiliary
> > > > function for this purpose.
> > > 
> > > Hmm, why wouldn't you just rename it to insn_get_reg_offset() and export it?
> > 
> > Do you mean exporting the structure that I mention above? The problem
> > that I am trying to solve is that callers sometimes want to know the
> > offset of the register encoded in the SiB or the ModRM bytes. I could
> > use something 
> > 
> > insn_get_reg_offset(insn, regs, INSN_TYPE_MODRM)
> > insn_get_reg_offset(insn, regs, INSN_TYPE_SIB)
> > 
> > Instead, I opted for
> > 
> > insn_get_reg_offset_rm(insn, regs)
> > insn_get_reg_offset_sib(insn, regs)
> > 
> > to avoid exposing an enum with the INSN_TYPE_MODRM, INSN_TYPE_SIB.
> 
> OK, if so, I think you should export both of them at once, not only
> insn_get_reg_offset_rm().

Sure, I will include both functions.

Thanks and BR,
Ricardo
> 
> Thank you,
> 
> > 
> > If you feel that the former makes more sense, I can change the
> > implementation.
> > 
> > Thanks and BR,
> > Ricardo
> > > 
> > > Thank you,
> > > 
> > > > 
> > > > Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> > > > Cc: Adam Buchbinder <adam.buchbinder@...il.com>
> > > > Cc: Colin Ian King <colin.king@...onical.com>
> > > > Cc: Lorenzo Stoakes <lstoakes@...il.com>
> > > > Cc: Qiaowei Ren <qiaowei.ren@...el.com>
> > > > Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> > > > Cc: Masami Hiramatsu <mhiramat@...nel.org>
> > > > Cc: Adrian Hunter <adrian.hunter@...el.com>
> > > > Cc: Kees Cook <keescook@...omium.org>
> > > > Cc: Thomas Garnier <thgarnie@...gle.com>
> > > > Cc: Peter Zijlstra <peterz@...radead.org>
> > > > Cc: Borislav Petkov <bp@...e.de>
> > > > Cc: Dmitry Vyukov <dvyukov@...gle.com>
> > > > Cc: Ravi V. Shankar <ravi.v.shankar@...el.com>
> > > > Cc: x86@...nel.org
> > > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
> > > > ---
> > > >  arch/x86/include/asm/insn-kernel.h | 1 +
> > > >  arch/x86/lib/insn-kernel.c         | 5 +++++
> > > >  2 files changed, 6 insertions(+)
> > > > 
> > > > diff --git a/arch/x86/include/asm/insn-kernel.h b/arch/x86/include/asm/insn-kernel.h
> > > > index aef416a..3f34649 100644
> > > > --- a/arch/x86/include/asm/insn-kernel.h
> > > > +++ b/arch/x86/include/asm/insn-kernel.h
> > > > @@ -12,5 +12,6 @@
> > > >  #include <asm/ptrace.h>
> > > >  
> > > >  void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
> > > > +int insn_get_reg_offset_rm(struct insn *insn, struct pt_regs *regs);
> > > >  
> > > >  #endif /* _ASM_X86_INSN_KERNEL_H */
> > > > diff --git a/arch/x86/lib/insn-kernel.c b/arch/x86/lib/insn-kernel.c
> > > > index 8072abe..267cab4 100644
> > > > --- a/arch/x86/lib/insn-kernel.c
> > > > +++ b/arch/x86/lib/insn-kernel.c
> > > > @@ -95,6 +95,11 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
> > > >  	return regoff[regno];
> > > >  }
> > > >  
> > > > +int insn_get_reg_offset_rm(struct insn *insn, struct pt_regs *regs)
> > > > +{
> > > > +	return get_reg_offset(insn, regs, REG_TYPE_RM);
> > > > +}
> > > > +
> > > >  /*
> > > >   * return the address being referenced be instruction
> > > >   * for rm=3 returning the content of the rm reg
> > > > -- 
> > > > 2.9.3
> > > > 
> > > 
> > > 
> > 
> > 
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ