Received: by 10.192.165.148 with SMTP id m20csp3550290imm; Mon, 30 Apr 2018 02:07:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrwFfmeDA7EBHMSU4aome7E7qn5yVdbojwkZd/ZIQ/cD1OvYdOdVL3WrvSXXkmkUXr2+FYK X-Received: by 2002:a17:902:2947:: with SMTP id g65-v6mr11494860plb.346.1525079235160; Mon, 30 Apr 2018 02:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079235; cv=none; d=google.com; s=arc-20160816; b=HGuvt4nI3+ShJ28Hs/CFq62c1WVNbUe6NQUorN0u5fotCDNXK6bwvKyKcZxRGh6+SI HmVbhAax03A+0EMtK9jSfegbcw2lLTyColD5N66AuRQxJETj7UAmBrsBwLOdnpPBIUj8 5eXFAf9YwMOp78nDVBJL+fgf8AG+KtGlUBBuLxvQ51pLGx4RPidVIi77BxVSGpXqc6Eb foOvjSLv/dKEqNEXtlMTxIkFizkfoKYRWjEMwup3dGrTtH840TJyiRytt68t3lcpIP+w B4C4PwERlqUy3nUuBa/QFmxUqjDGx25Ui/hPSoPYrppU9dYclRi1K50GTOaQE/J+A3jt fHng== 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=QTFgh5rnAgRbTkY/RyVI3T8EYB+f1yNxNf3TDi91iAg=; b=FWAg7D2CkLoQwiiTVV6UpNahOcufs6iswAo18wWFmIWe8tJZcJS6qgfrngVd6dRPGo IhSTZH5xjIEYQ+yfY+ELfP49m/j9ANiDVaIJozLMb9SDi6vGC72cP3Aoas0CFwVVxinH 8Ar2t+pLJ4Pz9Q/Q7q/TGIsC84veCoinuI5hXgVPHexjTtzxriRFa9hA5pj0FlwbiFjq +zdYhEPqITU2TA8x29ZyEE+9nGaWyX0tzr+wGdf5YFGAvyhecjuZKB6FBj0dY2XlUbaH AAh4uTHPGppPx/TmSkoAxypIFiJfWNUMBs+Bks9vCqdxEk5pm7Dug0U+MQi9g1u5XTs4 JufQ== 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 90-v6si7042531plc.205.2018.04.30.02.07.01; Mon, 30 Apr 2018 02:07:15 -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 S1752830AbeD3JGS (ORCPT + 99 others); Mon, 30 Apr 2018 05:06:18 -0400 Received: from mail.skyhub.de ([5.9.137.197]:59750 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751426AbeD3JGS (ORCPT ); Mon, 30 Apr 2018 05:06:18 -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 uQa_k0PxbQ5u; Mon, 30 Apr 2018 11:06:01 +0200 (CEST) Received: from pd.tnic (p200300EC2BC6BB0018CA5EB1E28A3112.dip0.t-ipconnect.de [IPv6:2003:ec:2bc6:bb00:18ca:5eb1:e28a:3112]) (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 2D82C1EC038F; Mon, 30 Apr 2018 11:06:00 +0200 (CEST) Date: Mon, 30 Apr 2018 11:05:42 +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 v5 6/6] x86/microcode/AMD: Check the equivalence table size when scanning it Message-ID: <20180430090542.GD6509@pd.tnic> References: <68fade9fda9e63c0722052abecaf4ed0c360beeb.1524515406.git.mail@maciej.szmigiero.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <68fade9fda9e63c0722052abecaf4ed0c360beeb.1524515406.git.mail@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 Mon, Apr 23, 2018 at 11:34:11PM +0200, Maciej S. Szmigiero wrote: > Currently, the code scanning the CPU equivalence table read from a > microcode container file assumes that it actually contains a terminating > zero entry. > Let's check also the size of this table to make sure that we don't read > past it in case it actually doesn't. ... > @@ -697,6 +706,7 @@ static unsigned int install_equiv_cpu_table(const u8 *buf, size_t buf_size) > } > > memcpy(equiv_cpu_table, buf + CONTAINER_HDR_SZ, equiv_tbl_len); > + equiv_cpu_table_entries = equiv_tbl_len / sizeof(struct equiv_cpu_entry); > > return equiv_tbl_len; Instead of adding yet another global var which needs handling too, and touching so many places, just do all checks and preparations in install_equiv_cpu_table() so that the rest of the code can get what it expects: terminating zero entry and proper size. Thx. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.