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]
Date:   Wed, 11 Oct 2017 17:45:54 -0700
From:   Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
To:     Borislav Petkov <bp@...e.de>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andy Lutomirski <luto@...nel.org>,
        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>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        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>,
        "Ravi V. Shankar" <ravi.v.shankar@...el.com>,
        Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org,
        x86@...nel.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: [PATCH v9 14/29] x86/insn-eval: Add utility function to get
 segment descriptor

On Wed, 2017-10-11 at 16:57 +0200, Borislav Petkov wrote:
> On Tue, Oct 03, 2017 at 08:54:17PM -0700, Ricardo Neri wrote:
> > 
> > The segment descriptor contains information that is relevant to how linear
> > addresses need to be computed. It contains the default size of addresses
> > as well as the base address of the segment. Thus, given a segment
> > selector, we ought to look at segment descriptor to correctly calculate
> > the linear address.
> > 
> > In protected mode, the segment selector might indicate a segment
> > descriptor from either the global descriptor table or a local descriptor
> > table. Both cases are considered in this function.
> ...
> 
> > 
> > +static struct desc_struct *get_desc(unsigned short sel)
> > +{
> > +	struct desc_ptr gdt_desc = {0, 0};
> > +	unsigned long desc_base;
> > +
> > +#ifdef CONFIG_MODIFY_LDT_SYSCALL
> > +	struct desc_struct *desc = NULL;
> > +	struct ldt_struct *ldt;
> You moved those out of the if-statement even though they're needed only
> in that scope. Why?

No reason, this is not correct. I will move them into the if-statement.


> Here's a diff that moves them back there and improves the function comment.
> 
> ---
> diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c
> index 62975f825556..c4e82bb4c4d3 100644
> --- a/arch/x86/lib/insn-eval.c
> +++ b/arch/x86/lib/insn-eval.c
> @@ -456,11 +456,11 @@ static int get_reg_offset(struct insn *insn, struct
> pt_regs *regs,
>  }
>  
>  /**
> - * get_desc() - Obtain address of segment descriptor
> + * get_desc() - Obtain pointer to a segment descriptor
>   * @sel:	Segment selector
>   *
> - * Given a segment selector, obtain a pointer to the segment descriptor.
> - * Both global and local descriptor tables are supported.
> + * Given a segment selector, obtain a pointer to the corresponding segment
> + * descriptor. Both global and local descriptor tables are supported.
>   *
>   * Returns:
>   *
> @@ -474,10 +474,10 @@ static struct desc_struct *get_desc(unsigned short sel)
>  	unsigned long desc_base;
>  
>  #ifdef CONFIG_MODIFY_LDT_SYSCALL
> -	struct desc_struct *desc = NULL;
> -	struct ldt_struct *ldt;
> -
>  	if ((sel & SEGMENT_TI_MASK) == SEGMENT_LDT) {
> +		struct desc_struct *desc = NULL;
> +		struct ldt_struct *ldt;
> +
>  		/* Bits [15:3] contain the index of the desired entry. */
>  		sel >>= 3;
> 

I will take your diff along with your Improvements-by: tag.

Thanks and BR,
Ricardo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ