From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 82DD2D80061 for ; Wed, 8 Nov 2023 20:11:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=dQqYxuWoBqzOc82to3nRmlz39q0gIN3Ytgr7ZYwoLEk=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699474269; v=1; b=HUXG5nmVu1JOw/YAsuKPQbhgd+L5vWipdc88a00GgahtShXn/JpqSfqFADevxZ9kVDb0ge7L 53A960o8m2/I1SHFvsyTvipy2JHbffF55EKzxqwClRclYfgLMYcAJv28g+ikwYFnZ4SUONSMQR4 FB7kcibEQH4aIrUS1Utqyu6U= X-Received: by 127.0.0.2 with SMTP id VMz6YY7687511xY64BT1qEay; Wed, 08 Nov 2023 12:11:09 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.25131.1699474268656085240 for ; Wed, 08 Nov 2023 12:11:08 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-uVntnARpNKmh-mZOVeGnAQ-1; Wed, 08 Nov 2023 15:11:04 -0500 X-MC-Unique: uVntnARpNKmh-mZOVeGnAQ-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 267EA3857B6A; Wed, 8 Nov 2023 20:11:04 +0000 (UTC) X-Received: from [10.39.192.41] (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E32521C060AE; Wed, 8 Nov 2023 20:11:02 +0000 (UTC) Message-ID: Date: Wed, 8 Nov 2023 21:11:01 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v4 3/4] StandaloneMmPkg/Core: Fix issue that offset calculation might be wrong To: devel@edk2.groups.io, wei6.xu@intel.com Cc: Ard Biesheuvel , Sami Mujawar , Ray Ni References: From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 3dXPNFWkmOG6XB4YEFBCk1lDx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=HUXG5nmV; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 11/6/23 08:52, Xu, Wei6 wrote: > 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. >=20 > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Cc: Ray Ni > Signed-off-by: Wei6 Xu > --- > StandaloneMmPkg/Core/FwVol.c | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) >=20 > 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; > } Reviewed-by: Laszlo Ersek -=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 (#110923): https://edk2.groups.io/g/devel/message/110923 Mute This Topic: https://groups.io/mt/102416001/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-