[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160227201259.GD19798@khazad-dum.debian.net>
Date: Sat, 27 Feb 2016 17:12:59 -0300
From: Henrique de Moraes Holschuh <hmh@....eng.br>
To: Borislav Petkov <bp@...en8.de>
Cc: Chris Bainbridge <chris.bainbridge@...il.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/microcode: Change checksum to u32
On Sat, 27 Feb 2016, Borislav Petkov wrote:
> * sum is computed here:
>
> sum = orig_sum
> - (mc_header->sig + mc_header->pf + mc_header->cksum)
> + (ext_sig->sig + ext_sig->pf + ext_sig->cksum);
Well, orig_sum is always zero, because we exit early when it isn't. sum
really ought to be u32 in the first place (the only reason the code works is
because gcc isn't that insane), and the other fields should have been cast
to u32 as well before being added, for clarity if nothing else.
> and it adds a bunch of integers which can overflow, sure, but if it
> overflows, we exit early.
There is no reason why "sig + pf + cksum" wouldn't overflow 32 bits... in
fact, they often (always?) do on valid microcode.
And we need all of the intel-microcode-checksum-related arithmetic to be
done modulo-2^32, because it is expected to overflow *and* warp around when
it does so.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
Powered by blists - more mailing lists