Message ID | 20230913183348.1349409-7-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:a8d:b0:3f2:4152:657d with SMTP id gr13csp58451vqb; Wed, 13 Sep 2023 13:08:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoyjeQb2kK/KRgyd6dUCOHyNYiTYptpJi6YlZEyuQPsZS1upqjWXJq2YLudYpSBjg/L6Sh X-Received: by 2002:a17:90b:4d85:b0:26c:f6d2:2694 with SMTP id oj5-20020a17090b4d8500b0026cf6d22694mr3330981pjb.12.1694635682554; Wed, 13 Sep 2023 13:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694635682; cv=none; d=google.com; s=arc-20160816; b=IBp0xlfa0tE6ljQh5/hFnN50bIAVyVwQfbAs5l+j9oMopjb4bAyeZPIDMB1wAulrNP x5rVCYG7Or/Iov1TXg+c9eCc03XfPctqrqX89aMp92kI+gSZuZhONZ7CzVPpeZqFhP7a 6jVt8GVlRSPTqnL1noc9rxu9eitm9F/5CLnEsDvviSBqwmnMY/96+x/p7Gb6m0GQ+8Ye DkaZkGtuIwW6zOMFccgf+637RC3A1j8xzd005t07KfO7Tk9M3/2523c/48648/Mt43JW /7qQKA6V7DEKqy0Wtrh1IlEaE6MqW2N7PBeIXHTGMS2GVEt8eN3E2+wtnAGHx2KLOOAP TD/g== 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=NRMsg5ftdqMaSRAJN9gPrIpxylk/Xfx5TJFB1AqXEuE=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=xa7eYw6uygLhxlqsV/IPl2xUFJrv5kFtiQ0Jdz9FVm3pyAeYxpyZDCwkjRaMI1+nco K0o9BT3iVmXu4GV6dPk8vBlJMQOJ9Rj/8mIDVYFzXqDZpncwYLKOsO5JqSNOt8vfr+nB 8kF8hklqsbmjRAkHv2U2CR0jzEIAjkXLOmwH1DOnrMUaLKvJyWggixE7qVdTlfOq+zqH hxFvRmFnQSdUk0wCA4TMANP3DzG2JbN5D8GHXzlBXRLGWf4aVk+IRR4e6m3dEH9QUuIy Gly052Cpc0xDMhGquqHTb3A1SSalg3iJpuXSFOrDqm0GcWWV5TafbtbNgh2SmNgnBTIL s3qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KmkCiurj; 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 q102-20020a17090a17ef00b0025c238650d1si24212pja.174.2023.09.13.13.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:08:02 -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=KmkCiurj; 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 A496E83F5327; Wed, 13 Sep 2023 11:38:21 -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 S231963AbjIMSiR (ORCPT <rfc822;pwkd43@gmail.com> + 34 others); Wed, 13 Sep 2023 14:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231897AbjIMSiA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 14:38:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A95C11BC6; Wed, 13 Sep 2023 11:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630276; x=1726166276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1QD1hfFNbY0dgb7El0Aw5L89YdqnDMRaACvnIzni/zs=; b=KmkCiurjD4OIJKYPCtR1x2bAZOtz1apLafTigQ6XdFkPtp3T0XfrOx/N 0cX645alEVU7+tytPxmwZOM1rh0IBUJNlAeZoYPxZ5insLq31iiMlu5T2 j6qL+8unc5Kqlti+IH7Kv0PgQKkB6xldueGN5YS/pRWR597H61WgT8+3V gSqdxCrCge8YE43qdeH3WgIJXof9mgEgFQwmCKgO/7b4R0juaJXm4DfI+ yANAoRumD4Qc4r3gn3Nv4K+m6l0JjxmT221j0SRnfNFG5I8HAhVQgT0Ha E17oB+vXiKRk2D22tiGm3vTsp0HKGnuytP291bGEgG0zTXyWHiTxHo2Uy g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019171" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019171" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 11:37:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238590" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238590" Received: from jithujos.sc.intel.com ([172.25.103.66]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 11:37:55 -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 Subject: [PATCH 06/10] platform/x86/intel/ifs: Validate image size Date: Wed, 13 Sep 2023 11:33:44 -0700 Message-Id: <20230913183348.1349409-7-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230913183348.1349409-1-jithu.joseph@intel.com> References: <20230913183348.1349409-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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]); Wed, 13 Sep 2023 11:38:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776954305697691553 X-GMAIL-MSGID: 1776954305697691553 |
Series |
IFS support for GNR and SRF
|
|
Commit Message
Jithu Joseph
Sept. 13, 2023, 6:33 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 Wed, 13 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. Please fix these short lines in all your patches. > 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 e8fb03dd8bcf..778a3b89a24d 100644 > --- a/drivers/platform/x86/intel/ifs/load.c > +++ b/drivers/platform/x86/intel/ifs/load.c > @@ -376,6 +376,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; > @@ -390,6 +391,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; > + } > + > ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); It looks than a bit odd to add the check here and not into a function called image_sanity_check()?!? > if (ret) > goto release; >
On 9/15/2023 9:57 AM, Ilpo Järvinen wrote: > On Wed, 13 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. > > Please fix these short lines in all your patches. Will do > >> 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 e8fb03dd8bcf..778a3b89a24d 100644 >> --- a/drivers/platform/x86/intel/ifs/load.c >> +++ b/drivers/platform/x86/intel/ifs/load.c >> @@ -376,6 +376,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; >> @@ -390,6 +391,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; >> + } >> + >> ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); > > It looks than a bit odd to add the check here and not into a function > called image_sanity_check()?!? image_sanity_check() validates the contents of the image, whereas the new check in some sense validates request_firmware_direct() results. Hence it was placed outside of content validation / closer to request_firmware_direct() Jithu
diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index e8fb03dd8bcf..778a3b89a24d 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -376,6 +376,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; @@ -390,6 +391,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; + } + ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); if (ret) goto release;