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: <20230928105205.GAZRVa1Rl0CPi-_cxX@fat_crate.local>
Date:   Thu, 28 Sep 2023 12:52:05 +0200
From:   Borislav Petkov <bp@...en8.de>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
        "Chang S. Bae" <chang.seok.bae@...el.com>,
        Arjan van de Ven <arjan@...ux.intel.com>,
        Nikolay Borisov <nik.borisov@...e.com>
Subject: Re: [patch V3 26/30] x86/microcode: Protect against instrumentation

On Tue, Sep 12, 2023 at 09:58:24AM +0200, Thomas Gleixner wrote:
>  	for (timeout = 0; timeout < USEC_PER_SEC; timeout++) {
> -		if (!atomic_read(cnt))
> +		if (!raw_atomic_read(cnt))
>  			return true;
> -		udelay(1);
> +
> +		for (loops = 0; loops < loops_per_usec; loops++)
> +			cpu_relax();
> +

Ah, you're dropping udelay because it is not noinstr...

> @@ -427,25 +464,43 @@ static void ucode_load_primary(unsigned
>  	}
>  }
>  
> -static bool microcode_update_handler(void)
> +static noinstr bool microcode_update_handler(void)
>  {
> -	unsigned int cpu = smp_processor_id();
> +	unsigned int cpu = raw_smp_processor_id();
>  
> -	if (this_cpu_read(ucode_ctrl.ctrl_cpu) == cpu)
> +	if (raw_cpu_read(ucode_ctrl.ctrl_cpu) == cpu) {
> +		instrumentation_begin();
>  		ucode_load_primary(cpu);
> -	else
> +		instrumentation_end();

Might as well make the load on the primary noinstr too. I wouldn't lose
any sleep over the late microcode loading code not being traceable.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ