Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1436970rdb; Mon, 2 Oct 2023 09:25:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDakm9bw0yrQUsQEAsHDyIdsu4SvRwGwTNUwj0e90cmOt8vMWV1ueawsxsnEymMGOLBavr X-Received: by 2002:a05:6870:a44e:b0:1d6:6083:63a3 with SMTP id n14-20020a056870a44e00b001d6608363a3mr13819336oal.37.1696263948566; Mon, 02 Oct 2023 09:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696263948; cv=none; d=google.com; s=arc-20160816; b=TkwTEpQAAAEIrsH8xfbq1QGvHec4GFTfU84KuGRpyAxY45HFzwehKJ1rF5HMOSYcGi Smj8c+KxyfnRv+bqFps21h6kQzQwPQlMBFMh1IK3sHDDWJ1loQRs6aKLeqU2bSyNUkSv tRaRKWGrNouaxdzd4U0nj4F6vqt5mZCsoCwiXyciuMpDWYI4gRmJBEwfVwEVCZrr+9gc t0I5O2+WwpntXD7waWgZ51MvHU8JE28nedkOOXVR83hFcLWJ32SWS0h7+xidvdt/DTDd 6h/yYckXGNh/bGxwZSxGLknh01FhmXgSb8cUw3GWwkoJdpaWoO9vPq+ETGnWE5UljgPY I6ZA== 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=Kv1YQTmR4Q+8MqLADEOlNPKrG0GbitkBWAmuuBK2bUc=; fh=Zx4D0zGMBj+9/N7d/Db2W7/hRmbrTS1pGT/B3fLoF6s=; b=OJXMsV4GvvxqOI1f6NSamIyC+jmSigF1jNSyTnkHZ0orMAxR8rwJl8mqrnwfURZH7M hqQcfl3a0bAL/bUtx5VWt+DbwaWwt4xq9LKA0hYhuKIaPhFjkV3QzZerxARWeReSPrO3 D94LFEqKB1/L3f4LyFW5V4HwqTO/dJKC4WhXp5KjOG/ev1fLnX08wjqLIykWOc/oKh0L ocyj+Aw5FNAv/FiSOhfKNBj0uKQQsM3fewUgbzIMpdBzPpuXo6a6jkAIuOs7pT5itW0P T4gbE2N3JOvLc0rNoP3PfECMgR9R0DDsDnhimbcvkklrbCi3KMV6bilcHEEofpGzn285 zpag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HxTUuytM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k6-20020a6568c6000000b005702c84e4c2si26915428pgt.508.2023.10.02.09.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HxTUuytM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 8E767807833B; Mon, 2 Oct 2023 04:51:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236747AbjJBLvH (ORCPT + 99 others); Mon, 2 Oct 2023 07:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236697AbjJBLvG (ORCPT ); Mon, 2 Oct 2023 07:51:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39C42C6; Mon, 2 Oct 2023 04:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696247463; x=1727783463; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=5jRlI7Om0cVUdpbhJuCnbv244tLYqa2yEKAiKz+E9FM=; b=HxTUuytMffSxDAih71YcGb7igjfLYUkk2i2j3rpuNDHbLvCXjcCj2zYV 8EWSCps9R39WQT2quUgyo7W8iVmg/9d2MGOfmWCdXyS0PTiGkT1/didfw POKzRaD3Ok35oQlXRhMhwWuiD/VQtGNnTQObQVx/zPWoo25UoNA5IAI7s rlUXY3oJvF1gSZWaRo4vHDAPVUomnVp3Gn698b9HBkWG0OafBm6aOaUmu +p4PGY+zqyDDoCYy4JB+UJmv3zRnBxf3dNhtK3to/SzWekvA3rngPCHNg DncgDgSb20sveR3OSar4n+nWEM6FruAhBsEFUnN5FvP6405YHPPxZhJjw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10850"; a="362003540" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362003540" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 04:51:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10850"; a="750558998" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="750558998" Received: from roliveir-mobl1.ger.corp.intel.com ([10.251.222.16]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 04:50:58 -0700 Date: Mon, 2 Oct 2023 14:50:55 +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 v3 5/9] platform/x86/intel/ifs: Validate image size In-Reply-To: Message-ID: References: <20230922232606.1928026-1-jithu.joseph@intel.com> <20230929202436.2850388-1-jithu.joseph@intel.com> <20230929202436.2850388-6-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-222638547-1696247462=:2459" 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 04:51:17 -0700 (PDT) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-222638547-1696247462=:2459 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT 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 > > 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..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 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. -- i. --8323329-222638547-1696247462=:2459--