[PATCH] x86/microcode: Add missing unlock in microcode_update_helper()

Alejandro Vallejo posted 1 patch 11 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230605150116.29911-1-alejandro.vallejo@cloud.com
xen/arch/x86/cpu/microcode/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] x86/microcode: Add missing unlock in microcode_update_helper()
Posted by Alejandro Vallejo 11 months, 1 week ago
microcode_update_helper() may return early while holding
cpu_add_remove_lock, hence preventing any writers from taking it again.

Leave through the `put` label instead so it's properly released.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
 xen/arch/x86/cpu/microcode/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index c1033f3bc2..e65af4b82e 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -599,7 +599,8 @@ static long cf_check microcode_update_helper(void *data)
         printk(XENLOG_WARNING
                "CPU%u is expected to lead ucode loading (but got CPU%u)\n",
                nmi_cpu, cpumask_first(&cpu_online_map));
-        return -EPERM;
+        ret = -EPERM;
+        goto put;
     }
 
     patch = parse_blob(buffer->buffer, buffer->len);
-- 
2.34.1
Re: [PATCH] x86/microcode: Add missing unlock in microcode_update_helper()
Posted by Andrew Cooper 11 months, 1 week ago
On 05/06/2023 4:01 pm, Alejandro Vallejo wrote:
> microcode_update_helper() may return early while holding
> cpu_add_remove_lock, hence preventing any writers from taking it again.
>
> Leave through the `put` label instead so it's properly released.

Fixes: 5ed12565aa32 ("microcode: rendezvous CPUs in NMI handler and load
ucode")

> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

I'll add the fixes on commit.

~Andrew