Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2819711rdb; Wed, 4 Oct 2023 12:23:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErg7F1BXOQKVS6fn5Un3ErqrAo5bq0uySnUx1qJnM9VHXtaXGiwFr2dQpKWdWkfihle9Yz X-Received: by 2002:a17:90a:d510:b0:274:98c4:b6e7 with SMTP id t16-20020a17090ad51000b0027498c4b6e7mr2856871pju.24.1696447428286; Wed, 04 Oct 2023 12:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696447428; cv=none; d=google.com; s=arc-20160816; b=dNSPkaZhH9bpjMigKCEUnn25zKl/VyY8DT72FHYviEaJ8D3vn1pG6h/icVxNDK0Qbj dzO11I6fPmZm3Fbu6Rna+cQbnqi+jyGQ7a9XKBXYXQknA2Kmu79gDzE5IahLoxhuU/Ye FtTA4BE/2TjeR3Kx4LEwGo5l+9FCoKvrtJFclcJwtnxDlI30E896/BBJO0xKRD8dRspR xoQ7ccDcnaRJWowL2rxHTvFd6hxSuk0+DNDVV8S87Yd6xX0LJOj7Fz7sqEdUj6Sd1xY9 GPVjI1rr9Sr2Tlyp6tTsKOoBpcI+uI0H5dkRADDDUUmA8nEfG0N2A6yGZH8enOQouH9/ VyEw== 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=Eg30xZ+9CXe85XHqy/+68h+/bOOzv8dtd0MESSRlfQk=; fh=DZTEBuCdFfe2DSdaI+6ceTR59ce872SNjmboNXW/0pA=; b=Czc07gQuZ4wV7Y3EL6HKVHp7XwRjVp8IpdFeFMshGpsJv1Q5pGUBzxI8day7L98o5y o5+XyDqNV3zGIqq/70J/M7IkUYdCaQ1aQ1HpFTxTLgUOkkerEFzf/U9Mi3qH1t+kBu5b aWhfbgSFFvUAfKU+zXPxM4NqG4AmmS9CSDKX1uUxeraM9mbasRQ08HFdBlnrdMtwEtw9 a76WishZhSjlb5mnLejYSyAzWhAGe/mocrtpoE5/JIrsSykFcS4UmwGCJNQWPMNp+HMm NjzrvsoG6C4qqyLMf0tXv4HyMkUbwHNCixwUFnjFiymILI6kgmN8N5zORYaT4SKEDnO8 CjWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m67+ql9A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id pg2-20020a17090b1e0200b0026d4adee541si2042034pjb.150.2023.10.04.12.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m67+ql9A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 0E244827177A; Wed, 4 Oct 2023 12:23:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245533AbjJDTIH (ORCPT + 99 others); Wed, 4 Oct 2023 15:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245237AbjJDTHh (ORCPT ); Wed, 4 Oct 2023 15:07:37 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2F135A6; Wed, 4 Oct 2023 12:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696446254; x=1727982254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9rEhsAdm4qprufCY9YFBrMJoK6i9PZwnuJiNdBtxSWU=; b=m67+ql9A/+xqQEzFpZDrCpdf4eH0sSSFaCVTWu1G4V5Yp/wU93QemSmA g5DE9DglETUMPHLkQJypQt9he8rQHFCXKm07gloInEZWUinsHnbhGr3hG A/DXWwtJ/E/37je1ALV2iXv8wqVMo8dFijtVAvEJyiJbUo9E5azlKHNb4 P4W/AgQGd4GF3tae/mktarsJcKsHC6zzemEkhUWMS9EoOZcPz3iYFsAlP VE+n0LgN0uOr1pjTi9noODT3epuzI3B6TCsI8TpJ9ZNVSIckmRlylnjqt EHaR98ctJuvBaDtnhA80viMMmFvU8kgXFUWphRi6Aq7cWQoMfjemfu3A6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10853"; a="4838619" X-IronPort-AV: E=Sophos;i="6.03,201,1694761200"; d="scan'208";a="4838619" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2023 12:04:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10853"; a="745098524" X-IronPort-AV: E=Sophos;i="6.03,201,1694761200"; d="scan'208";a="745098524" Received: from jithujos.sc.intel.com ([172.25.103.66]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2023 12:04:12 -0700 From: Jithu Joseph 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 6/9] platform/x86/intel/ifs: Metadata validation for start_chunk Date: Wed, 4 Oct 2023 12:00:09 -0700 Message-Id: <20231004190009.3028495-1-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 12:23:47 -0700 (PDT) Add an additional check to validate IFS image metadata field prior to loading the test image. If start_chunk is not a multiple of chunks_per_stride error out. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- - changed the dev_warn printk format specifiers (Ilpo Järvinen) drivers/platform/x86/intel/ifs/load.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index 582f1801aaaa..959b1878cae6 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -291,6 +291,13 @@ static int validate_ifs_metadata(struct device *dev) return ret; } + if (ifs_meta->chunks_per_stride && + (ifs_meta->starting_chunk % ifs_meta->chunks_per_stride != 0)) { + dev_warn(dev, "Starting chunk num %u not a multiple of chunks_per_stride %u\n", + ifs_meta->starting_chunk, ifs_meta->chunks_per_stride); + return ret; + } + return 0; } -- 2.25.1