[edk2-devel] [PATCH 1/1] StandaloneMmPkg: Fix the failure to find uncompressed inner FV.

Xu, Wei6 wei6.xu at intel.com
Fri Oct 27 02:21:20 UTC 2023


Hi Laszlo,

Thanks a lot for the review.

I send review the patch v2 to fix:
- memory leaks on error paths
- missing object size checks before casting pointers to header types
(https://edk2.groups.io/g/devel/message/110160)

Regarding to 'unbounded recursion', I couldn't come up with a good solution to fix the problem, let's fix the others first.


BR,
Wei

-----Original Message-----
From: Laszlo Ersek <lersek at redhat.com> 
Sent: Tuesday, October 24, 2023 8:03 PM
To: devel at edk2.groups.io; Xu, Wei6 <wei6.xu at intel.com>
Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>; Sami Mujawar <sami.mujawar at arm.com>; Ni, Ray <ray.ni at intel.com>
Subject: Re: [edk2-devel] [PATCH 1/1] StandaloneMmPkg: Fix the failure to find uncompressed inner FV.

On 10/24/23 07:53, Xu, Wei6 wrote:
> 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.
> 
> Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
> Cc: Sami Mujawar <sami.mujawar at arm.com>
> Cc: Ray Ni <ray.ni at intel.com>
> Signed-off-by: Wei6 Xu <wei6.xu at intel.com>
> ---
>  StandaloneMmPkg/Core/FwVol.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/StandaloneMmPkg/Core/FwVol.c 
> b/StandaloneMmPkg/Core/FwVol.c index 1f6d7714ba97..1a85d80eb9f7 100644
> --- a/StandaloneMmPkg/Core/FwVol.c
> +++ b/StandaloneMmPkg/Core/FwVol.c
> @@ -104,6 +104,17 @@ MmCoreFfsFindMmDriver (
>        break;
>      }
>  
> +    Status = FfsFindSectionData (
> +               EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
> +               FileHeader,
> +               &SectionData,
> +               &SectionDataSize
> +               );
> +    if (!EFI_ERROR (Status)) {
> +      InnerFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)SectionData;
> +      MmCoreFfsFindMmDriver (InnerFvHeader);
> +    }
> +
>      Status = FfsFindSectionData (
>                 EFI_SECTION_GUID_DEFINED,
>                 FileHeader,

I'd recommend fixing other, more foundational issues first, in this function, such as:

- memory leaks on error paths

- unbounded recursion

- missing object size checks before casting pointers to header types

At the same time I agree that this change doesn't seem to make things worse than they are.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110166): https://edk2.groups.io/g/devel/message/110166
Mute This Topic: https://groups.io/mt/102152694/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list