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-next>] [day] [month] [year] [list]
Date:   Fri, 19 Mar 2021 18:48:14 +0000
From:   "Pontes, Otavio" <otavio.pontes@...el.com>
To:     "x86@...nel.org" <x86@...nel.org>
CC:     Borislav Petkov <bp@...en8.de>,
        Thomas Gleixner <tglx@...utronix.de>,
        "Raj, Ashok" <ashok.raj@...el.com>,
        "Luck, Tony" <tony.luck@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] x86/microcode: Check for offline CPUs before checking
 for microcode update

Sorry, I forgot to copy LKML

________________________________________
From: Pontes, Otavio <otavio.pontes@...el.com>
Sent: Friday, March 19, 2021 9:55 AM
To: x86@...nel.org
Cc: Borislav Petkov; Thomas Gleixner; Pontes, Otavio; Raj, Ashok; Luck, Tony
Subject: [PATCH 1/1] x86/microcode: Check for offline CPUs before checking for microcode update

Checking for any offline CPUs to abort microcode update must be done before
kernel caching a new microcode from the filesystem. Otherwise when offlined
CPUs are onlined later, those cores are going to be updated with the new
microcode while CPUs previously onine will continue to run with the older
microcode. If update is aborted before checking for the microcode file,
offline CPUs that are onlined later will get the same microcode as online
CPUs.

Turn off one core (2 threads)
$ echo 0 > /sys/devices/system/cpu/cpu3/online
$ echo 0 > /sys/devices/system/cpu/cpu1/online

Install the ucode fails because there's one core off
$ cp intel-ucode/06-8e-09 /lib/firmware/intel-ucode/
$ echo 1 > /sys/devices/system/cpu/microcode/reload
bash: echo: write error: Invalid argument

Turn the core back on
$ echo 1 > /sys/devices/system/cpu/cpu3/online
$ echo 1 > /sys/devices/system/cpu/cpu1/online
$ cat /proc/cpuinfo |grep microcode
microcode : 0x30
microcode : 0xde
microcode : 0x30
microcode : 0xde

Fixes: 30ec26da9967 ("x86/microcode: Do not upload microcode if CPUs are offline")
Signed-off-by: Otavio Pontes <otavio.pontes@...el.com>
Acked-by: Ashok Raj <ashok.raj@...el.com>
Reviewed-by: Tony Luck <tony.luck@...el.com>
---
 arch/x86/kernel/cpu/microcode/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index b935e1b5f115..6a6318e9590c 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -629,16 +629,16 @@ static ssize_t reload_store(struct device *dev,
        if (val != 1)
                return size;

-       tmp_ret = microcode_ops->request_microcode_fw(bsp, &microcode_pdev->dev, true);
-       if (tmp_ret != UCODE_NEW)
-               return size;
-
        get_online_cpus();

        ret = check_online_cpus();
        if (ret)
                goto put;

+       tmp_ret = microcode_ops->request_microcode_fw(bsp, &microcode_pdev->dev, true);
+       if (tmp_ret != UCODE_NEW)
+               goto put;
+
        mutex_lock(&microcode_mutex);
        ret = microcode_reload_late();
        mutex_unlock(&microcode_mutex);
--
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ