Re: [PATCH 1/2] x86, microcode: Sanitize per-cpu microcode reloadinginterface

From: Borislav Petkov
Date: Tue Jun 19 2012 - 19:38:07 EST


On Tue, Jun 19, 2012 at 11:15:56PM +0000, Yu, Fenghua wrote:
> > diff --git a/arch/x86/kernel/microcode_core.c
> > b/arch/x86/kernel/microcode_core.c
> > index fbdfc6917180..24b852b61be3 100644
> > --- a/arch/x86/kernel/microcode_core.c
> > +++ b/arch/x86/kernel/microcode_core.c
> > @@ -298,19 +298,31 @@ static ssize_t reload_store(struct device *dev,
> > const char *buf, size_t size)
> > {
> > unsigned long val;
> > - int cpu = dev->id;
> > - ssize_t ret = 0;
> > + int cpu;
> > + ssize_t ret = 0, tmp_ret;
> > +
> > + /* allow reload only from the BSP */
> > + if (boot_cpu_data.cpu_index != dev->id)
> > + return -EINVAL;
>
> With the /sys/devices/system/cpu/microcode/reload interface in your
> patch 2/2, this will be broken, right?

Actually it works per chance and passed testing. And I think I know why:
now the reload sysfs node is not per-cpu, this dev->id is always 0 and
thus the check passes.

> With the new interface, reload_store() can be executed on any cpu or
> dev. I think you need to remove this check if working with the patch
> 2/2.

But you're right, will fix.

Thanks for the review.

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/