Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1358117rdh; Mon, 25 Sep 2023 10:10:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgd1K5171hzBnZZnW7OGYVrLgbbuYoQ+FMI0MRZUIZJNEuo95azIcqVVuYgZ+idRxodnFO X-Received: by 2002:a05:6358:52d2:b0:140:f00a:ee2d with SMTP id z18-20020a05635852d200b00140f00aee2dmr10039371rwz.23.1695661815932; Mon, 25 Sep 2023 10:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695661815; cv=none; d=google.com; s=arc-20160816; b=ItHd5HxnU5zyjOTwVKT/ktvV0qZ35Yz7hXlQqNJc+ee0F093XuOsaVjbXgGl6VA8nL fevxAzjCUD8CGfxJNG0HPF+dGqaxTU4HNElKDSMQep4ZPl2cXpb27DgHR9jvqb15V8Eo FfH+yxB/WNzbPIhc6+iq2ff6JLi4IaLXPjHSPl2WdL0F9x1zGGs6KwJ+6o0+99Bmh+Io cUtWfnSa6uT8FKjSP7WurgMjJQXJmZbaXWNmCZJfbURshhj1GXO3juYGSMReeSh87A82 UkIq8xppXmGOmpO96v/z4XpxlRviNHo3h8qvd/IUZgszjcRcBr2kkhJXMh8WC4XwZCQk zu8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=MV2kN2Fgc/p9b8R5WXnsAcS3ZqIvD0NsWkQrPAtEXyc=; fh=Zx4D0zGMBj+9/N7d/Db2W7/hRmbrTS1pGT/B3fLoF6s=; b=FPRv2hkGsSuQJ5jWeMP44ayC+UCDBIcq1Z8g2osAoEltvLCvY+OneDix9ci7xtr9Nh 3T0ys4fk5/jxqrkk4S4hRjJLtS/smyO52zbs8gSGfRgz1zwzCz6jgqJJ4KNHuw1GkYrc UN/rzSQtkjR5fM4DlpP8V3ae60SKuZedEjOt1xg+nRYNjaMXFNXnMYiVMq2zzqI6MY3/ JFGrtSVvHLdjaO2A+zM4ArRvXsQgDe9piu0nZhEuLSfTFtbqh97FWWplYJ1mBTHFh+PY 6ONjwjPYsN8qg18JyOH224IhU8ect6ti6satGivKhmKkU0BHnOnBorzjjIkbvWMGJy6c qPhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JlC5QpAY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b17-20020a656691000000b005648d20203dsi10659213pgw.233.2023.09.25.10.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JlC5QpAY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2515280763FA; Mon, 25 Sep 2023 08:45:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbjIYPoW (ORCPT + 99 others); Mon, 25 Sep 2023 11:44:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233287AbjIYPoG (ORCPT ); Mon, 25 Sep 2023 11:44:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25F0E66; Mon, 25 Sep 2023 08:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695656614; x=1727192614; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=KBtV9Wt5TwMqqcq4D9cO2jjNjTy6l+lb5oWWBcyEU1Q=; b=JlC5QpAYi6V08OoibbDy269r7g8ybSxZgYnffJoMyZ3iUTxRWvCrMuZ8 hxuVwJLj7pH1uzU+3ttlAvm1IzOXX/wEvcyrvFFnPfvwFz6HjBlbz3G7X xdExxJRv8KF0J2J+f1E2lK9ARn6Q3VGDzQ2ctth7asXLVuYayiHUBgS5G Wkt08yowhaJhdwh8EG+rzQftXXyQ0mdzAQAl+fKVJ38c7o+qisrSezQIH cJkks/yy1O3xMpVzCHn5N6QhIBXsVW7cE1P2FPL+GplNk73JfbbE93qPD r60kVY2OY+kguPuj3lpbMRZvm3MqO/ZgZHH0nmJMakrQX2KxnIUzDQ5rS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="361536153" X-IronPort-AV: E=Sophos;i="6.03,175,1694761200"; d="scan'208";a="361536153" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 08:43:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="872090067" X-IronPort-AV: E=Sophos;i="6.03,175,1694761200"; d="scan'208";a="872090067" Received: from stamengx-mobl1.ger.corp.intel.com ([10.249.32.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 08:43:27 -0700 Date: Mon, 25 Sep 2023 18:43:24 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Jithu Joseph cc: Hans de Goede , markgross@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, rostedt@goodmis.org, ashok.raj@intel.com, tony.luck@intel.com, LKML , platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, ravi.v.shankar@intel.com, pengfei.xu@intel.com Subject: Re: [PATCH v2 5/9] platform/x86/intel/ifs: Validate image size In-Reply-To: <20230922232606.1928026-6-jithu.joseph@intel.com> Message-ID: <318e7426-fcab-c1e4-6e84-752c332088f2@linux.intel.com> References: <20230913183348.1349409-1-jithu.joseph@intel.com> <20230922232606.1928026-1-jithu.joseph@intel.com> <20230922232606.1928026-6-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:45:34 -0700 (PDT) On Fri, 22 Sep 2023, Jithu Joseph wrote: > Perform additional validation prior to loading IFS image. > > Error out if the size of the file being loaded doesn't match the size > specified in the header. > > Signed-off-by: Jithu Joseph > Reviewed-by: Tony Luck > Tested-by: Pengfei Xu > --- > drivers/platform/x86/intel/ifs/load.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c > index 6b827247945b..b09106034fac 100644 > --- a/drivers/platform/x86/intel/ifs/load.c > +++ b/drivers/platform/x86/intel/ifs/load.c > @@ -375,6 +375,7 @@ int ifs_load_firmware(struct device *dev) > { > const struct ifs_test_caps *test = ifs_get_test_caps(dev); > struct ifs_data *ifsd = ifs_get_data(dev); > + unsigned int expected_size; > const struct firmware *fw; > char scan_path[64]; > int ret = -EINVAL; > @@ -389,6 +390,13 @@ int ifs_load_firmware(struct device *dev) > goto done; > } > > + expected_size = ((struct microcode_header_intel *)fw->data)->totalsize; > + if (fw->size != expected_size) { > + dev_err(dev, "File size mismatch (expected %d, actual %ld). Corrupted IFS image.\n", > + expected_size, fw->size); > + return -EBADFD; I don't think this error code is best suited for what occurred. I guess returning just -EINVAL would be fine. -- i. > + } > + > ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); > if (ret) > goto release; >