From nobody Mon Feb 9 03:47:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110739+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110739+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699257196; cv=none; d=zohomail.com; s=zohoarc; b=L9ueZ9JVnTMXdXqiROI0QAPwpu66xlDCDypO5FQbZrVaSRsrM4cfws7l5jlNOMHd/wDENtC2Uh3dGZCntasry5jCfIXgjRK06a3LB66ThWsQa5I6sfaOC4017EtQ+g+u6vS8ER5HOqn2bNiMQ57gIUCwt9WhM4X6usCZEAT9dZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699257196; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=FEx+cddqPfTPhqGnyK+vDZDryc6CQX0xI+Qzmi7OSxY=; b=DeGOK54xnEtegkavr3/+/7qiNmE6RWdPvQov2A+G3ZC6hcn+1zy0tmce7zNuryo+rjn1auHmMQMPen8A+4ekMMLRBBzRaHqaKCk10j0UIJwDVqqGbRgb0kS73B3ooJFJekhK8DR+BVGaGeYW6XioTfiRfJAb4cM40DYJw8Y0Gbo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110739+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699257196012158.53371186711774; Sun, 5 Nov 2023 23:53:16 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=fm5sXqnulGCDME6ugEVR/oSxdhXjBrnCdYZAZ8mVJ5I=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699257195; v=1; b=Kk6kZqv3QulU7wuebnQ6ISJji4SxrY4KSf5PnCD1pUymsrJIoyfuCWfz5yesl/mK9PoDzrcb uh8dcIqgR0DhM3k5Qi6T+O6POjFpVgmXQ+fUMh8eZNUmPGq6iPxUiRVy3dZHBe41gb8BGlQUMSe +WyXi0fBIsax2ptauHlIMVnQ= X-Received: by 127.0.0.2 with SMTP id LEtwYY1788612x42aPSWnuCc; Sun, 05 Nov 2023 23:53:15 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.49168.1699257184993246575 for ; Sun, 05 Nov 2023 23:53:15 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="453535789" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="453535789" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 23:53:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="885824615" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="885824615" X-Received: from shpfwdbuild003.ccr.corp.intel.com ([10.239.56.82]) by orsmga004.jf.intel.com with ESMTP; 05 Nov 2023 23:53:12 -0800 From: "Xu, Wei6" To: devel@edk2.groups.io Cc: Wei6 Xu , Laszlo Ersek , Ard Biesheuvel , Sami Mujawar , Ray Ni Subject: [edk2-devel] [PATCH v4 3/4] StandaloneMmPkg/Core: Fix issue that offset calculation might be wrong Date: Mon, 6 Nov 2023 15:52:58 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wei6.xu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: lIeewQlv5kIlnOG3bwT7sxI6x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699257196901100001 Content-Type: text/plain; charset="utf-8" MmCoreFfsFindMmDriver() assumes FileHeader is EFI_FFS_FILE_HEADER. If FileHeader is an EFI_FFS_FILE_HEADER2, 'FileHeader + 1' will get a wrong section address. Use FfsFindSection to get the section directly, instead of 'FileHeader + 1' to avoid this issue. MmCoreFfsFindMmDriver() also assumes section is EFI_COMMON_SECTION_HEADER. If Section is EFI_COMMON_SECTION_HEADER2, 'Section + 1' will get a wrong wrong InnerFvHeader adress. Add section head detection and calculate the address accordingly. Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Ray Ni Signed-off-by: Wei6 Xu Reviewed-by: Laszlo Ersek --- StandaloneMmPkg/Core/FwVol.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/StandaloneMmPkg/Core/FwVol.c b/StandaloneMmPkg/Core/FwVol.c index c3054ef751ed..4d2b63a448e7 100644 --- a/StandaloneMmPkg/Core/FwVol.c +++ b/StandaloneMmPkg/Core/FwVol.c @@ -79,8 +79,6 @@ MmCoreFfsFindMmDriver ( UINTN DepexSize; UINTN Index; EFI_COMMON_SECTION_HEADER *Section; - VOID *SectionData; - UINTN SectionDataSize; UINT32 DstBufferSize; VOID *ScratchBuffer; UINT32 ScratchBufferSize; @@ -117,23 +115,21 @@ MmCoreFfsFindMmDriver ( break; } =20 - Status =3D FfsFindSectionData ( + Status =3D FfsFindSection ( EFI_SECTION_GUID_DEFINED, FileHeader, - &SectionData, - &SectionDataSize + &Section ); if (EFI_ERROR (Status)) { break; } =20 - Section =3D (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1); - Status =3D ExtractGuidedSectionGetInfo ( - Section, - &DstBufferSize, - &ScratchBufferSize, - &SectionAttribute - ); + Status =3D ExtractGuidedSectionGetInfo ( + Section, + &DstBufferSize, + &ScratchBufferSize, + &SectionAttribute + ); if (EFI_ERROR (Status)) { break; } @@ -194,8 +190,13 @@ MmCoreFfsFindMmDriver ( goto FreeDstBuffer; } =20 - InnerFvHeader =3D (VOID *)(Section + 1); - Status =3D MmCoreFfsFindMmDriver (InnerFvHeader, Depth + 1); + if (IS_SECTION2 (Section)) { + InnerFvHeader =3D (VOID *)((EFI_COMMON_SECTION_HEADER2 *)Section + 1= ); + } else { + InnerFvHeader =3D (VOID *)(Section + 1); + } + + Status =3D MmCoreFfsFindMmDriver (InnerFvHeader, Depth + 1); if (EFI_ERROR (Status)) { goto FreeDstBuffer; } --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110739): https://edk2.groups.io/g/devel/message/110739 Mute This Topic: https://groups.io/mt/102416001/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-