From nobody Tue May 14 00:14:46 2024 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+110161+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+110161+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1698368370; cv=none; d=zohomail.com; s=zohoarc; b=RddE6uZPRLv5z+M4dAyq1bUZyH3w5Z6/KqyxmC/K5WRfPRBG2n7ql8kYJo6FtbEWhMHCMo6azNfJ3uVHqwd9HN5brFR8G4lbgB44tPtlUUqNpKTjQYzn1cxPeupUeQBC9PP72Suf2nD36I4JlaA/nPbRPxF+DoMdtp6gT+6tayw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698368370; 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=YaTYcEMJxRHJ93Q5HaHMvFv25s/SMP8MPu4fl8iexRk=; b=dhKWqSFSJ3gK+G7g4zwzSAE2VnzYd2jHf/zCQWRZtcK9noImjXXlzsk3gAYzRDzNak81LQhU8jB8MT2cb5C2LbuWKTtBQGL+RQEXXVIKfKzV9s+2GO8D0dtDVdwJmHMvJuN2MUoHKRrhh8sJBL6CacxLVrpyEksobGN9yVvheds= 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+110161+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 1698368370629206.2199662698987; Thu, 26 Oct 2023 17:59:30 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=pu9mSrgMNnMsQtRQA/kmDaiVKb77/SXA0iJqrXsEE54=; 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=1698368370; v=1; b=VAckT5CpONvi/e2RfC4WQClMHKdMJ0cYfse+/FT40LdsUUpxy8Nvh4NOy8/fHMPnvNUjdIZd r646Kdye46BO74mSJR4jAXVOt3rD6ETsz/TagkPAeDNQtTEBroaLxzcx5K9czHX0FLWklttaB+Q B5v+flGIrOHPLDD4rIkq4l3I= X-Received: by 127.0.0.2 with SMTP id aj67YY1788612xvEBOOTbHn8; Thu, 26 Oct 2023 17:59:30 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.87089.1698368365478454309 for ; Thu, 26 Oct 2023 17:59:29 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="451926113" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="451926113" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 17:59:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="883027068" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="883027068" X-Received: from shpfwdbuild003.ccr.corp.intel.com ([10.239.56.82]) by orsmga004.jf.intel.com with ESMTP; 26 Oct 2023 17:59:27 -0700 From: "Xu, Wei6" To: devel@edk2.groups.io Cc: Wei6 Xu , Laszlo Ersek , Ard Biesheuvel , Sami Mujawar , Ray Ni Subject: [edk2-devel] [PATCH v2 1/1] StandaloneMmPkg: Fix some issues in function MmCoreFfsFindMmDriver. Date: Fri, 27 Oct 2023 08:59:20 +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: jqPDcNtGeD5WYlOBAt6BPblOx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698368371482100001 Content-Type: text/plain; charset="utf-8" 1. The MmCoreFfsFindMmDriver only checks for encapsulated compressed FVs. When an inner FV is uncompressed, StandaloneMmCore will miss the FV and all the MM drivers in the FV will not be dispatched. Add checks for uncompressed inner FV to fix this issue. 2. 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. 3. ScratchBuffer is not freed in the error return path that DstBuffer page allocation fails. Free ScratchBuffer before return with error. Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Ray Ni Signed-off-by: Wei6 Xu --- StandaloneMmPkg/Core/FwVol.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/StandaloneMmPkg/Core/FwVol.c b/StandaloneMmPkg/Core/FwVol.c index 1f6d7714ba97..fb483bd62696 100644 --- a/StandaloneMmPkg/Core/FwVol.c +++ b/StandaloneMmPkg/Core/FwVol.c @@ -104,23 +104,40 @@ MmCoreFfsFindMmDriver ( break; } =20 + // + // Check uncompressed firmware volumes + // Status =3D FfsFindSectionData ( - EFI_SECTION_GUID_DEFINED, + EFI_SECTION_FIRMWARE_VOLUME_IMAGE, FileHeader, &SectionData, &SectionDataSize ); + if (!EFI_ERROR (Status)) { + if (SectionDataSize > sizeof (EFI_FIRMWARE_VOLUME_HEADER)) { + InnerFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)SectionData; + MmCoreFfsFindMmDriver (InnerFvHeader); + } + } + + // + // Check compressed firmware volumes + // + Status =3D FfsFindSection ( + EFI_SECTION_GUID_DEFINED, + FileHeader, + &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; } @@ -138,6 +155,7 @@ MmCoreFfsFindMmDriver ( // DstBuffer =3D (VOID *)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (DstBuff= erSize)); if (DstBuffer =3D=3D NULL) { + FreePages (ScratchBuffer, EFI_SIZE_TO_PAGES (ScratchBufferSize)); return EFI_OUT_OF_RESOURCES; } =20 --=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 (#110161): https://edk2.groups.io/g/devel/message/110161 Mute This Topic: https://groups.io/mt/102212658/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-