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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 16 Aug 2016 12:49:52 -0700
From:	Kees Cook <keescook@...omium.org>
To:	Borislav Petkov <bp@...en8.de>
Cc:	Brian Gerst <brgerst@...il.com>, Baoquan He <bhe@...hat.com>,
	Yinghai Lu <yinghai@...nel.org>,
	Juergen Gross <jgross@...e.com>,
	Thomas Garnier <thgarnie@...gle.com>,
	Andy Lutomirski <luto@...nel.org>,
	"H. Peter Anvin" <hpa@...or.com>,
	Alexander Kuleshov <kuleshovmail@...il.com>,
	Josh Poimboeuf <jpoimboe@...hat.com>,
	Christian Borntraeger <borntraeger@...ibm.com>,
	Stephen Smalley <sds@...ho.nsa.gov>,
	"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
	Joerg Roedel <jroedel@...e.de>,
	"Williams, Dan J" <dan.j.williams@...el.com>,
	Mark Salter <msalter@...hat.com>, Borislav Petkov <bp@...e.de>,
	Jonathan Corbet <corbet@....net>,
	Matt Fleming <matt@...eblueprint.co.uk>,
	Xiao Guangrong <guangrong.xiao@...ux.intel.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
	Ingo Molnar <mingo@...nel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Toshi Kani <toshi.kani@....com>,
	Alexander Popov <alpopov@...ecurity.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Jan Beulich <JBeulich@...e.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Boris Ostrovsky <boris.ostrovsky@...cle.com>,
	Denys Vlasenko <dvlasenk@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Dave Young <dyoung@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	Lv Zheng <lv.zheng@...el.com>,
	Martin Schwidefsky <schwidefsky@...ibm.com>,
	"linux-tip-commits@...r.kernel.org" 
	<linux-tip-commits@...r.kernel.org>
Subject: Re: [tip:x86/boot] x86/mm: Enable KASLR for physical mapping memory regions

On Tue, Aug 16, 2016 at 10:50 AM, Borislav Petkov <bp@...en8.de> wrote:
> On Tue, Aug 16, 2016 at 05:54:12PM +0200, Borislav Petkov wrote:
>> Ok, I ran this in a guest and it finds the microcode patches properly.
>
> Here's a better version to take care of the APs too:
>
> ---
> diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
> index 27a0228c9cae..05242322e324 100644
> --- a/arch/x86/kernel/cpu/microcode/amd.c
> +++ b/arch/x86/kernel/cpu/microcode/amd.c
> @@ -355,6 +355,7 @@ void load_ucode_amd_ap(void)
>         unsigned int cpu = smp_processor_id();
>         struct equiv_cpu_entry *eq;
>         struct microcode_amd *mc;
> +       u8 *cont;
>         u32 rev, eax;
>         u16 eq_id;
>
> @@ -371,8 +372,12 @@ void load_ucode_amd_ap(void)
>         if (check_current_patch_level(&rev, false))
>                 return;
>
> +#ifdef CONFIG_RANDOMIZE_MEMORY
> +       cont = container + PAGE_OFFSET - __PAGE_OFFSET_BASE;
> +#endif
> +
>         eax = cpuid_eax(0x00000001);
> -       eq  = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ);
> +       eq  = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ);

Am I misreading this? Shouldn't it be:

       cont = container;
#ifdef CONFIG_RANDOMIZE_MEMORY
       cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
#endif

(otherwise cont is undefined in the RANDOMIZE_MEMORY=n case?)

>
>         eq_id = find_equiv_id(eq, eax);
>         if (!eq_id)
> @@ -434,6 +439,10 @@ int __init save_microcode_in_initrd_amd(void)
>         else
>                 container = cont_va;
>
> +#ifdef CONFIG_RANDOMIZE_MEMORY
> +       container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
> +#endif
> +
>         eax   = cpuid_eax(0x00000001);
>         eax   = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
>
>
> --
> Regards/Gruss,
>     Boris.
>
> ECO tip #101: Trim your mails when you reply.
> --


-Kees

-- 
Kees Cook
Nexus Security

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ