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:   Fri, 22 Jun 2018 17:35:18 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
cc:     Ingo Molnar <mingo@...hat.com>, x86@...nel.org,
        "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH REBASED RESEND] x86/cpu: Move early cpu initialization
 into a separate translation unit

On Fri, 22 Jun 2018, Kirill A. Shutemov wrote:
> On Fri, Jun 22, 2018 at 02:05:47PM +0000, Thomas Gleixner wrote:
> > On Tue, 12 Jun 2018, Kirill A. Shutemov wrote:
> > 
> > > __pgtable_l5_enabled shouldn't be needed after system has booted, we can
> > > mark it as __initdata, but it requires preparation.
> > > 
> > > This patch moves early cpu initialization into a separate translation
> > > unit. This limits effect of USE_EARLY_PGTABLE_L5 to less code.
> > > 
> > > Without the change cpu_init() uses __pgtable_l5_enabled. cpu_init() is
> > > not __init function and it leads to section mismatch.
> > > 
> > > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> > > Reviewed-by: Thomas Gleixner <tglx@...utronix.de>
> > 
> > Second thoughts.
> > 
> > The only place where __pgtable_l5_enabled() is used in common.c is in
> > early_identify_cpu() which is marked __init. So how is that section
> > mismatch triggered?
> 
> Yeah, it's not obvious:
> 
> cpu_init()
>   load_mm_ldt()
>     ldt_slot_va()
>       LDT_BASE_ADDR
>         LDT_PGD_ENTRY
> 	  pgtable_l5_enabled()

How is that supposed to work correctly?

start_kernel()
  ....
  trap_init()
    cpu_init()

  ....
  check_bugs()
    alternative_instructions()

So the first invocation of cpu_init() on the boot CPU will then use
static_cpu_has() which is not yet initialized proper.

So, no. That does not work and the proper fix is:

-unsigned int __pgtable_l5_enabled __initdata;
+unsigned int __pgtable_l5_enabled __ro_after_init;

and make cpu/common.c use the early variant. The extra 4 bytes storage are
not a problem and cpu_init() is not a fast path at all.

Thanks,

	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ