From: "Laszlo Ersek" <lersek@redhat.com>
To: Wei6 Xu <wei6.xu@intel.com>, devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Sami Mujawar <sami.mujawar@arm.com>, Ray Ni <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH v3 3/4] StandaloneMmPkg/Core: Fix issue that section address might be wrong
Date: Mon, 30 Oct 2023 13:38:55 +0100 [thread overview]
Message-ID: <7a1106c7-ab64-f3fb-dc6b-fdd62ca836b7@redhat.com> (raw)
In-Reply-To: <f9ac81ab3186d5156befd8a0d1551b8f37edca47.1698651605.git.wei6.xu@intel.com>
On 10/30/23 08:49, Wei6 Xu 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.
>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
> ---
> StandaloneMmPkg/Core/FwVol.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/StandaloneMmPkg/Core/FwVol.c b/StandaloneMmPkg/Core/FwVol.c
> index 9d0ce66ef839..fa335d62c252 100644
> --- a/StandaloneMmPkg/Core/FwVol.c
> +++ b/StandaloneMmPkg/Core/FwVol.c
> @@ -116,23 +116,21 @@ MmCoreFfsFindMmDriver (
> break;
> }
>
> - Status = FfsFindSectionData (
> + Status = FfsFindSection (
> EFI_SECTION_GUID_DEFINED,
> FileHeader,
> - &SectionData,
> - &SectionDataSize
> + &Section
> );
> if (EFI_ERROR (Status)) {
> break;
> }
>
> - Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
> - Status = ExtractGuidedSectionGetInfo (
> - Section,
> - &DstBufferSize,
> - &ScratchBufferSize,
> - &SectionAttribute
> - );
> + Status = ExtractGuidedSectionGetInfo (
> + Section,
> + &DstBufferSize,
> + &ScratchBufferSize,
> + &SectionAttribute
> + );
> if (EFI_ERROR (Status)) {
> break;
> }
(1) Can you remove the SectionData and SectionDataSize variables as
well? I think they are unused at this point.
With that:
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Ah wait, you're going to use those variables in the next patch, again.
OK then. Just take my R-b for this patch.
(2) Now that I'm looking at the code in more depth, I don't even
understand what the original intent of the FfsFindSectionData() call was!
The output values SectionData and SectionDataSize were not used for
anything!
So it seems like FfsFindSectionData() was called just to make sure an
EFI_SECTION_GUID_DEFINED section *existed*. And then we'd treat the very
*first* section after the file header -- not too robustly identified, at
that -- as a GUIDed section, for extracting its info.
So this patch actually fixes two warts: one, the file header size is now
considered more generally, two, we don't just assume that the very first
section is the GUID-defined section, but look it up. Phew.
Laszlo
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110315): https://edk2.groups.io/g/devel/message/110315
Mute This Topic: https://groups.io/mt/102270548/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-10-30 12:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 7:49 [edk2-devel] [PATCH v3 0/4] StandaloneMmCore finds drivers in uncompressed inner fv Xu, Wei6
2023-10-30 7:49 ` [edk2-devel] [PATCH v3 1/4] StandaloneMmPkg/Core: Limit FwVol encapsulation section recursion Xu, Wei6
2023-10-30 11:44 ` Laszlo Ersek
2023-10-30 7:49 ` [edk2-devel] [PATCH v3 2/4] StandaloneMmPkg/Core: Fix potential memory leak issue Xu, Wei6
2023-10-30 12:24 ` Laszlo Ersek
2023-10-31 6:40 ` Xu, Wei6
2023-10-31 8:37 ` Xu, Wei6
2023-10-31 11:43 ` Laszlo Ersek
2023-11-06 7:55 ` Xu, Wei6
2023-10-30 7:49 ` [edk2-devel] [PATCH v3 3/4] StandaloneMmPkg/Core: Fix issue that section address might be wrong Xu, Wei6
2023-10-30 12:38 ` Laszlo Ersek [this message]
2023-10-30 7:49 ` [edk2-devel] [PATCH v3 4/4] StandaloneMmPkg/Core: Fix the failure to find uncompressed inner FV Xu, Wei6
2023-10-30 12:54 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7a1106c7-ab64-f3fb-dc6b-fdd62ca836b7@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox