Received: by 10.213.65.68 with SMTP id h4csp616507imn; Tue, 20 Mar 2018 10:55:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELvF+nHb45OfsXnc5iOXd6D9WrgSxwhLpbBmq7/iAQOavFOmEx4yZ+YTy+86vEQTuTbMzUG6 X-Received: by 2002:a17:902:50ec:: with SMTP id c41-v6mr16984701plj.208.1521568537853; Tue, 20 Mar 2018 10:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521568537; cv=none; d=google.com; s=arc-20160816; b=DmMWzTLJLk6Hx77vwQ5ZbrAzXJe1WrLPfpcFRa8UC3NJeLvW7IRRixva8bL1H+HOkr Jk6Ib9EwsHq5Ph9qglbgQq83LDWYDuq7oWCLgulp64hquWsaPE5x33hiuInW3qPQP9Vi kpZiGELQx0AN32LZWvBVOEZo6cOtJmNdMXigaDFNEqpXWx5LfGLqtvo7HGNE9i7mGlAD noMF1//ev9AeaFyDpKbMixfSCcv4hz5Ca/yg3CcL7TaOMWPE8I6CbczU5wMaDzCar1y8 mj8mcNI/Un2y/0bHBJPJYLMPMyuWi+4MnHTkzlYteQHx/11vmZl4WvqZtkbsNXppdR9n ohJQ== 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=D8VXII9HLSBedGoi9SJT1TAdsGScHT0bLsJ0vYOt1Rg=; b=w65Fm9aauRVvkKEiUimWljjQLB3IHnS9Wkzs4uf693I3qLrgmxnmpNLpUx1yblgT0Q i17JI6dufNf54cEtwG4L/PFDqcg4T4tMgMlexxkwnaaEflwqFrX8Db6Ry6fTkLxWfJFN rKto2vWIOccUdtRYzrZuksNCj7kVu9qf3OtgwT5oXcv0DuQWujLZFe7dyt9FJRNrhuUl A1rHZ7AstqZmld9nnNR4j4BKoYf5j3MT3t/bgrKIT+a5idFb55kGstGTmRn8joZVgshs SDSWoGQrFArAqNkRu6f8ftogn6BzUPk5LmySLSkep8DyWt5j7hPGY3w0+CD1fQQGGpvx gulA== 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 i33-v6si2124076pld.627.2018.03.20.10.55.23; Tue, 20 Mar 2018 10:55:37 -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 S1751688AbeCTRyX (ORCPT + 99 others); Tue, 20 Mar 2018 13:54:23 -0400 Received: from mail.skyhub.de ([5.9.137.197]:54214 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbeCTRyW (ORCPT ); Tue, 20 Mar 2018 13:54:22 -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 u7n5bF1vZ1e0; Tue, 20 Mar 2018 18:54:05 +0100 (CET) Received: from pd.tnic (unknown [165.204.77.1]) (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 9DAE71EC0299; Tue, 20 Mar 2018 18:54:04 +0100 (CET) Date: Tue, 20 Mar 2018 18:53:36 +0100 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 v4 03/10] x86/microcode/AMD: Check equivalence table length in the late loader Message-ID: <20180320175308.GA9360@cz.tnic> References: <1f29f9f9-0a9e-11e2-8e61-ba7c171e2bd9@maciej.szmigiero.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1f29f9f9-0a9e-11e2-8e61-ba7c171e2bd9@maciej.szmigiero.name> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 16, 2018 at 12:08:04AM +0100, Maciej S. Szmigiero wrote: > Before loading a CPU equivalence table from a microcode container file we > need to verify whether this file is actually large enough to contain the > table of a size indicated in this file. > If it is not, there is no point of continuing with loading it since > microcode patches are located after the equivalence table anyway. > > This patch adds these checks to the late loader. > > Signed-off-by: Maciej S. Szmigiero > --- > arch/x86/kernel/cpu/microcode/amd.c | 32 ++++++++++++++++++++++---------- > 1 file changed, 22 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c > index 138c9fb983f2..ed24200cf936 100644 > --- a/arch/x86/kernel/cpu/microcode/amd.c > +++ b/arch/x86/kernel/cpu/microcode/amd.c > @@ -551,28 +551,40 @@ static enum ucode_state apply_microcode_amd(int cpu) > return UCODE_UPDATED; > } > > -static int install_equiv_cpu_table(const u8 *buf) > +static int install_equiv_cpu_table(const u8 *buf, size_t buf_size) > { > unsigned int *ibuf = (unsigned int *)buf; > - unsigned int type = ibuf[1]; > - unsigned int size = ibuf[2]; > + unsigned int type, equiv_tbl_len; Ok, as a unification, let's make those u32 too. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. Srsly.