From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992559AbcB0UNF (ORCPT ); Sat, 27 Feb 2016 15:13:05 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:35628 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756711AbcB0UND (ORCPT ); Sat, 27 Feb 2016 15:13:03 -0500 X-Sasl-enc: vrhXtZV3j/nUcl2klI9e7i6O4TBoyEHb+2CJEtmZyyu0 1456603981 Date: Sat, 27 Feb 2016 17:12:59 -0300 From: Henrique de Moraes Holschuh To: Borislav Petkov Cc: Chris Bainbridge , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/microcode: Change checksum to u32 Message-ID: <20160227201259.GD19798@khazad-dum.debian.net> References: <1456570907-5344-1-git-send-email-chris.bainbridge@gmail.com> <20160227175118.GC5261@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160227175118.GC5261@pd.tnic> X-GPG-Fingerprint1: 4096R/39CB4807 C467 A717 507B BAFE D3C1 6092 0BD9 E811 39CB 4807 User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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