Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp641674imm; Tue, 5 Jun 2018 01:54:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJLVT7rh4zCw5YwzWtg9vXG/BjbyIqMseZG/y/Fb6LCOuimIVKdUjE9N1AvZSAiIPrJAEwn X-Received: by 2002:a62:574d:: with SMTP id l74-v6mr7648070pfb.29.1528188887764; Tue, 05 Jun 2018 01:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528188887; cv=none; d=google.com; s=arc-20160816; b=K2lhiKTMNPONvjQIX/Y1dFaLywy9GNQuH3CINt5S7oBvWz1GDolHU0cZj9Yr/vvoeP DrzZ2QAdLoXt/sIAQCqwqzt3eu6BTJ+kw9kKc6LijuU4B+E2ZToR3z9vScVPTgd1Q9v5 vtcPS4ldjmHlWWSMvKjQdHB6yQTA9iAXddg3fip7V/e/9jRcfUEdE59mJMfHzi81d6P/ d8KKVt+AXUsBp3s+vMDpKHCc8x6FvRwKRpQXM8z2Q4O6MmnOv8gzy0j2zKvesrV7q4g/ lPP8E8jFtrzS2uZFl1O33qufZXYL8Ic/hsaunSG5ALYCSaMOiYHhItEtxgd+9CvitwUp /3Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=b2zbK/6tYlaWcdqbYRF2NSvo0jeu/W0o8EF3A/LhkXk=; b=SnaWYUTAbjt8FsJ68z37JSOE4SU+HmgjLFFtSOxgXnfiUe008eNgA28eLli6xihJXd 18qL5q1JMBTEBdy9czuXQrsPgIDmiLKWimY7232BBgOt77pUVee68DO8RlvMYhJzKCcQ ViOPE00DTHag3+J5fNLIuId5LCj/1C72plpIA+7/2xJq+jn3AnhXLBXYoV0CrZK4rxA0 qWjDTLbnSzGRhbfwVtQF4Iu12k6ho1K4FMyedExDfCyKM5+JZS6j7ljYYs/TlCZUsKbr 1/rQLSJ7dkspDkslb2PqFclOSJsWeiT7IqSt2Qmoc8zL0i+A8DFrKVnEk1uAILcpxRrK k0ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si47694021pld.424.2018.06.05.01.54.33; Tue, 05 Jun 2018 01:54:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751666AbeFEIyF (ORCPT + 99 others); Tue, 5 Jun 2018 04:54:05 -0400 Received: from mail.skyhub.de ([5.9.137.197]:50656 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751354AbeFEIyD (ORCPT ); Tue, 5 Jun 2018 04:54:03 -0400 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lwBKk-TEIb9Y; Tue, 5 Jun 2018 10:54:02 +0200 (CEST) Received: from zn.tnic (p200300EC2BCEAD00329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2bce:ad00:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 618221EC0346; Tue, 5 Jun 2018 10:54:02 +0200 (CEST) Date: Tue, 5 Jun 2018 10:54:04 +0200 From: Borislav Petkov To: "Maciej S. Szmigiero" Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/8] x86/microcode/AMD: Add microcode container data checking functions Message-ID: <20180605085403.GA1617@zn.tnic> References: <28d0439f64e03e3c8192e1f5280f01a5729698fc.1526767245.git.mail@maciej.szmigiero.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <28d0439f64e03e3c8192e1f5280f01a5729698fc.1526767245.git.mail@maciej.szmigiero.name> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 20, 2018 at 12:07:16AM +0200, Maciej S. Szmigiero wrote: > Add verify_container(), verify_equivalence_table(), verify_patch_section() > and verify_patch() functions to the AMD microcode update driver. > > These functions check whether a passed buffer contains the relevant > structure, whether it isn't truncated and (for actual microcode patches) > whether the size of a patch is not too large for a particular CPU family. > By adding these checks as separate functions the actual microcode loading > code won't get interspersed with a lot of checks and so will be more > readable. > > Signed-off-by: Maciej S. Szmigiero > --- > arch/x86/kernel/cpu/microcode/amd.c | 148 +++++++++++++++++++++++++++- > 1 file changed, 145 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c > index dc8ea9a9d962..f9485ff7183c 100644 > --- a/arch/x86/kernel/cpu/microcode/amd.c > +++ b/arch/x86/kernel/cpu/microcode/amd.c > @@ -73,6 +73,150 @@ static u16 find_equiv_id(struct equiv_cpu_entry *equiv_table, u32 sig) > return 0; > } > > +/* > + * Checks whether there is a valid microcode container file at the beginning "Check whether... " imperative tone. Ditto for the rest. > + * of a passed buffer @buf of size @size. @buf_size Also, fix the other comments too. > + * If @early is set this function does not print errors which makes it > + * usable by the early microcode loader. > + */ > +static bool verify_container(const u8 *buf, size_t buf_size, bool early) ... -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.