Re: [PATCH v2] x86/microcode/AMD: check microcode file sanity before loading it
From: Maciej S. Szmigiero
Date: Mon Mar 12 2018 - 10:10:55 EST
On 12.03.2018 14:48, Borislav Petkov wrote:
> On Mon, Mar 12, 2018 at 02:32:30PM +0100, Maciej S. Szmigiero wrote:
>> "microcode_amd.bin" in linux-firmware.
>
> That is the microcode container for all families < 0x15. And it
> *happens* to have 18 entries.
>
> So purely arbitrary:
>
> Equivalence table (magic: AMD, type: 0, length: 288 (0x120))
(the long table was cut)
>
>> There is no problem raising this value in that (future) case.
>> As I wrote previously, currently the maximum used count is 18.
>
> There is a problem because not everyone can upgrade their kernels
> like you. Distros and big deployments can't just up and update their
> kernels at a whim just because you imposed an arbitrary limit which you
> determined would be ok.
First, this limit is more than 14 times higher than the current maximum
count.
And this current maximum was reached by CPU types added in
families < 15h during last 10+ years (the oldest supported CPU family in
this container is 10h, which - according to Wikipedia - was released
September 10, 2007).
At that rate exceeding this limit will take 130+ additional years (and
this assumes that AMD will introduce new CPU types in these families
at the same rate as in the last 10 years - I sincerely doubt it).
If somebody does not update their kernel for 130 years (even to -stable
versions) then he or she has a much bigger problem than incompatibility
with the current microcode update file.
>
>> Not really, since even in the existing code CONTAINER_HDR_SZ (12) gets
>> added to this size, then the sum is cast to a (signed) int.
>> If this value is negative then the file get rejected.
>
> That is a bug in install_equiv_cpu_table() - it should return unsigned int.
>
>> It can be changed to the current maximum across sizes for particular
>
> What is the "current maximum across sizes"?
>
This is the current maximum patch size across families:
#define F15H_MPB_MAX_SIZE 4096
Maciej