Message ID | 20230929202436.2850388-6-jithu.joseph@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp147025vqb; Fri, 29 Sep 2023 18:51:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjNl5viM2+Kao5HsP7d46Lri5pzOgstjMk9K8v00mmEDlyUv+KBsBYGh9tiwMtcMuDZT64 X-Received: by 2002:a05:6808:191a:b0:3ae:1254:ea8a with SMTP id bf26-20020a056808191a00b003ae1254ea8amr7766578oib.41.1696038702978; Fri, 29 Sep 2023 18:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696038702; cv=none; d=google.com; s=arc-20160816; b=LOZ/XEcnh8ZTuPzOCYcI5fX1UNIRwrRvLsQymclntHUqq5N2rVYs2Tqtx6V2zEPLJD zXKdjyzAfoF8Bzk3iTSpq7zNn1CDNCPNcsZ4ZL/rboMCeMs6hWp/2iiCd3TBZZ/5wDph h8xViUYmK7rTjR6xFVutFbWaq/W1uY7figmgPukzaWCh5tc2oIvdDW+sVFE7ubckg4YA R8GP/0Z8DNz18ikxp35RS5ahBeupNi1X0KYABt6PlaWJyuM8OFP01BT6ScbCIG6z4wtZ UmeEnjzwPA8Sx/HTskZGno/eO3Gawa0G6lgyR31U21ZFYFvekMUonlBrDbmOBjbbqeIV X87w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Bqj4mG9txmrPkkjf2oCH3Pf8ALKTSxdhNA63Hh0WDAo=; fh=DZTEBuCdFfe2DSdaI+6ceTR59ce872SNjmboNXW/0pA=; b=ae2NA51mslkpe/fy7/E+LwOEvcex5wnSjRiNxZXLmzAi0/pRwTdDmcbNzAvz56tu9d AzDHxfhxX4t64mmonqotNGzD9Ap/cLNLB2aMpsY/AJKjbwkGmb9MOaGmzqRQCpIUWcA1 Otwz4s9EfUUkjSgPaOaRs1uunBH1Qc3zy7p2E1+GDkSXvkbIvBUX8Q7P1Ryr58Q1MUeU r4S3OGCgOW8EP/tWP0APbW0qZo9q4/diN59K0KWKP/HssadcjCZdoT2FFt8ttUgjp0Ej VfBwkUop6mpIpysn3L2kZlK5BCkKeVhWQKcrGpHpUzuBEbuxF/M8iiM2e1fLjMGK4C49 BO1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WI1idGjn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q83-20020a632a56000000b005702257f32esi21368742pgq.185.2023.09.29.18.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 18:51:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WI1idGjn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 8BAB180A8575; Fri, 29 Sep 2023 13:45:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233952AbjI2Upm (ORCPT <rfc822;pwkd43@gmail.com> + 19 others); Fri, 29 Sep 2023 16:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbjI2Up1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 29 Sep 2023 16:45:27 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6D561B9; Fri, 29 Sep 2023 13:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696020324; x=1727556324; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5hK8PYdSqpMVTtIO5x+qGkBJOJzZIeEW/a5RmMzipn4=; b=WI1idGjnod0AUE7lht+lm/cl6rHSrXvVhrchdAyIJ3rfsXaA2/MJQRDB CmBDUj/EChSjvTWBUuvbs7AAo/cfPBeV0E8Aj23EP3qbKVyUpsKmjHM9S bgnJfgoN2i5jrAuAqj/Rz6GZDItkaP3bWiNXouH0wbEYxM4mw1ON3Wp9f g04FFXzryt+504ToSgYMAvwIwvSVeyq7nKlRoxaSqyMvWBvKutHDI9Xjz ZJXj5g9Eh2JRBk7MgT/5xh/tZ/JmkmROs4Z0qRstbMOW9X1b9xQc/9goT po6S/peTMa6wLYS60909d9gHXEWoAf4npkoMZr+JrvgOIrktaIUPmg1Ik w==; X-IronPort-AV: E=McAfee;i="6600,9927,10848"; a="468654460" X-IronPort-AV: E=Sophos;i="6.03,188,1694761200"; d="scan'208";a="468654460" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 13:28:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10848"; a="893539240" X-IronPort-AV: E=Sophos;i="6.03,188,1694761200"; d="scan'208";a="893539240" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 13:27:29 -0700 From: Jithu Joseph <jithu.joseph@intel.com> To: hdegoede@redhat.com, markgross@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, rostedt@goodmis.org, jithu.joseph@intel.com, ashok.raj@intel.com, tony.luck@intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, ravi.v.shankar@intel.com, pengfei.xu@intel.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 5/9] platform/x86/intel/ifs: Validate image size Date: Fri, 29 Sep 2023 13:24:32 -0700 Message-Id: <20230929202436.2850388-6-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230929202436.2850388-1-jithu.joseph@intel.com> References: <20230922232606.1928026-1-jithu.joseph@intel.com> <20230929202436.2850388-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 13:45:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776954305697691553 X-GMAIL-MSGID: 1778425478667009311 |
Series |
IFS support for GNR and SRF
|
|
Commit Message
Jithu Joseph
Sept. 29, 2023, 8:24 p.m. UTC
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 <jithu.joseph@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Tested-by: Pengfei Xu <pengfei.xu@intel.com> --- drivers/platform/x86/intel/ifs/load.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Comments
On Fri, 29 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 <jithu.joseph@intel.com> > Reviewed-by: Tony Luck <tony.luck@intel.com> > Tested-by: Pengfei Xu <pengfei.xu@intel.com> > --- > 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..da54fd060878 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 -EINVAL; > + } > + > ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); > if (ret) > goto release; > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
On Mon, 2 Oct 2023, Ilpo Järvinen wrote: > On Fri, 29 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 <jithu.joseph@intel.com> > > Reviewed-by: Tony Luck <tony.luck@intel.com> > > Tested-by: Pengfei Xu <pengfei.xu@intel.com> > > --- > > 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..da54fd060878 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 -EINVAL; > > + } > > + > > ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); > > if (ret) > > goto release; > > > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Just after sending the rev-by, I realized this also has %d vs unsigned int problem, and %ld should be using %zu as fw->size of size_t. Feel free to add my rev-by after those two problems have been fixed.
On 10/2/2023 4:50 AM, Ilpo Järvinen wrote: > On Mon, 2 Oct 2023, Ilpo Järvinen wrote: >> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > Just after sending the rev-by, I realized this also has %d vs unsigned int > problem, and %ld should be using %zu as fw->size of size_t. > > Feel free to add my rev-by after those two problems have been fixed. > Thanks for the review. I will make this change Jithu
diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index 6b827247945b..da54fd060878 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 -EINVAL; + } + ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); if (ret) goto release;