Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp525721rdb; Thu, 5 Oct 2023 12:57:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGc+y6mWPSCMpmd1qlw9iKqbbF3GhGsXlVuo1Cd9tsj+9YexBbVBeI1B3OJLbCDD06nH7j X-Received: by 2002:a05:6a20:549e:b0:161:28e0:9abd with SMTP id i30-20020a056a20549e00b0016128e09abdmr7661958pzk.16.1696535822522; Thu, 05 Oct 2023 12:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696535822; cv=none; d=google.com; s=arc-20160816; b=lcc+JN4DfZAC1p5Lp9mQ8wQOkVGzgtfUqEZGTbOIZy9LEIDvg2jS5V1/WHkvaRArQM /bZ97oqnZBSsueP/NjCKphXTPZqNLGq+BvTvKDLfWi+ME/aPSsQciX8nM8c4jc3/1qyb mp73tMxsxM2PxaKyp1ft5uPXp5sRuj2FPF2I9sAH1ybHhwFm0VHQ66j5l7yyS2plAYfn Wg58gaPWMM3u2+/GHq7fVLNFB+fQZFZV/BVOe5HHdUnZNWrFAk7q58jbOnvB+vbk1YA6 cVDlkK5y8Z5jrScQ9cWy/N40+0RBA3JKtLNXgmvgBOCLOnvoW6b/6aTp73Jg6yY+SEha QCxQ== 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=OAAHaKEwde5h+emjPCyFOrXJfJP0AVWDPkKpG8dqmnk=; fh=dyN8rlR8DIsO7hGArNuYLUXtXvDlE6dkZecyfb1jp0w=; b=HMj5t8AbZxs+lN3mc70ye8H+iNPEpYMODNpDu6gt2kRaqjlp3KQHiH+bkkpMd+/O/l 1K3L1PRrSSSPBNqY+xgCT8QN7fqZeET65oQ7Wc1pzjryzjHeyGQ7vsm1AuUdQh4I/uj4 KLhIIQ0XVVGBqSIcxvoJwHE6vpDv2pf0R595MGY2nlOYcAL6mgCbxWNGKqgizgxVnaIF rK48anZkdVvofZNBenIVrFAcmC5u7P4jnRkiqKrzuBG5W7Qe+QL85GLgNitnYmCuw4VY 57/DeX8Q2R+cTny1eDhORDHOkZQ1KBq7lvra5gVVUddlhHJ4YJw4RzIstQ1ybbZWl7L8 MhSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fd42rx4u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ea24-20020a056a004c1800b0069026fd5a31si2010323pfb.272.2023.10.05.12.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 12:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fd42rx4u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id F1BC4807F4BB; Thu, 5 Oct 2023 12:56:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbjJET4M (ORCPT + 99 others); Thu, 5 Oct 2023 15:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbjJETzt (ORCPT ); Thu, 5 Oct 2023 15:55:49 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F50E8; Thu, 5 Oct 2023 12:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696535749; x=1728071749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QMn5zpNP8+ffHcP9eBj+rXkV8aG9ATI7kUf+LVAcPHo=; b=fd42rx4u0SehggpgZ+MxmRhqMCWlJkvoPkJzReImALVsTcF5PnQIjOym fw+LZb5DLIgS3Sj+FszX+j3StV73Wsq+DSPR9j1m9NZsFPT1ObhK4s4mz Gv4JEG40ARlGDnPUOvO+nx6zUHVwyt4Cbp8akvsILE0FVW/83MF9pg8/Z ObzeNFs1zzY+2qIBkJBW82zLIfS+tq/d35fTAI3ni3+4Ls9JnaglNZHqN zxQJQfLbhcI2wL4lGyGI1ytZcIZ8LdyBB0RI3xXVT8xQLrZkU+zb7pSkh bPUPIPFAoUgX9/k8H1wi8EdLrR3Ls8ZDlBGxohvjUXPrv9oSQ8n0nF5la A==; X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="386432585" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="386432585" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 12:55:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="755600134" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="755600134" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 12:55:44 -0700 From: Jithu Joseph To: ilpo.jarvinen@linux.intel.com, 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 v4 6/9] platform/x86/intel/ifs: Metadata validation for start_chunk Date: Thu, 5 Oct 2023 12:51:34 -0700 Message-Id: <20231005195137.3117166-7-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231005195137.3117166-1-jithu.joseph@intel.com> References: <20230929202436.2850388-1-jithu.joseph@intel.com> <20231005195137.3117166-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 05 Oct 2023 12:56:56 -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 --- 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