From patchwork Wed Sep 13 18:33:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joseph, Jithu" X-Patchwork-Id: 13383669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC475EE0207 for ; Wed, 13 Sep 2023 18:38:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231936AbjIMSiE (ORCPT ); Wed, 13 Sep 2023 14:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbjIMSiB (ORCPT ); Wed, 13 Sep 2023 14:38:01 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C58BA3; Wed, 13 Sep 2023 11:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630277; x=1726166277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=27uuSgwznKYWiVr2rzZGk8zPvF6mY8zY3sne3jlCPzw=; b=DWixgxhi9Wc+QQu863a2xfIfb363nxibe+8INkzu0gFUZFgQ70wDmh3X Pl8vH6ho2uuh5E6YIyBHYtxZBAnzIWv2uiaBCwm8Iuy0IABqvg0Y8NAD0 MjbCqk1Axs859rylCYxs56pPDGUpH97X9at0VZ6m23yQz15IKx0AmGwPB amOk7X4x+Eo4XEcLT7ORH0flqiuy5McpGsdtST+/VBEXc/+Q79zqL0elg T98mZitDM8wvJbgrHUq57DkDSltjXpcThkHTRhINQCadQx/w/bDtVPrZ4 V7+jMi2s6ePiWy6/WjSXH6TTppKsh68ZgUuzzyjC0nedulJGGAPyI9NQn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019182" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019182" 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="744238595" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238595" 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:56 -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 Subject: [PATCH 07/10] platform/x86/intel/ifs: Metadata validation for start_chunk Date: Wed, 13 Sep 2023 11:33:45 -0700 Message-Id: <20230913183348.1349409-8-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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org 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 --- 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 778a3b89a24d..88630366a23c 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -292,6 +292,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)) { + dev_warn(dev, "Starting chunk num %d not a multiple of chunks_per_stride %d\n", + ifs_meta->starting_chunk, ifs_meta->chunks_per_stride); + return ret; + } + return 0; }