From nobody Sat May 4 22:49:49 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+78891+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+78891+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=posteo.de ARC-Seal: i=1; a=rsa-sha256; t=1628451641; cv=none; d=zohomail.com; s=zohoarc; b=E9kJSQqNRBHy+tAaILID7gqMz5b+kMB4F/3650ogFSZUg5iRYyf5UmRg9Te5cS7ieMUQ+4nuUJhsT2WKTzsrT5xSWLfRmybSask/Trjsg0tveSF1AYrGi/1DlNYRHAkpTOPedHvYrUyNbuFfOfQyz+MN/jwWAwLRRRtE67707e4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628451641; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=HeR+n/nkEaZ/8HaAFfNd/SiBTWpXLP/doiLqtp4K4E8=; b=RfaA9o5H/cZoV5tvObNdfTKVTQ1mE0nszrSf5v1YB3mr+QIQTdKWmCfchcL9bNTby83nqiT8O9Y5g/k11+w72tIg6bJ7AARaUpvCA/RBeEQspPkrAe0QqbKLW2+y91UWyVsnj1LQ5jYXJ7e5h02n8qlacu726b6x8i8am9AOasU= 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+78891+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 1628451641289319.56826038952886; Sun, 8 Aug 2021 12:40:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id P4RLYY1788612x9KEX3nxQF2; Sun, 08 Aug 2021 12:40:41 -0700 X-Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web10.13765.1628451639767462387 for ; Sun, 08 Aug 2021 12:40:40 -0700 X-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id EFEC4240104 for ; Sun, 8 Aug 2021 21:40:37 +0200 (CEST) X-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GjV1d2kB4z6tmF; Sun, 8 Aug 2021 21:40:37 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Jiewen Yao , Supreeth Venkatesh , Vitaly Cheptsov Subject: [edk2-devel] [PATCH] StandaloneMmPkg/FvLib: Correct FV section data size Date: Sun, 8 Aug 2021 19:39:49 +0000 Message-Id: In-Reply-To: <5df11a13422732b9c03c120775a2b4dd0a49182f.1628444003.git.mhaeuser@posteo.de> References: <5df11a13422732b9c03c120775a2b4dd0a49182f.1628444003.git.mhaeuser@posteo.de> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,mhaeuser@posteo.de X-Gm-Message-State: scN3Gy86xvlTXxO7BV3mrmdAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1628451641; bh=xfipibeg2KOSGMMeor/0dbde+z2tZtuKv09LjCrYgpk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=hP/K/bP03X4oNMrXMVv92ulDmEdIhqUQuBJuWUdDWqdgC+iwaOa3PACVY0UDfknzE0x LNibf2vDno5bQuHxvGRvBziGZvMcy5duCUro2hI5176hwZY/yjM3a+BWZBD6qVReSpQ8Y HkMIJOS1BG2cbDV+pOSDGDk6im4pVLb9fcs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628451641812100056 Content-Type: text/plain; charset="utf-8" The size of a FV section includes the size of its header. Subtract latter to yield the correct size of the contained data. Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Jiewen Yao Cc: Supreeth Venkatesh Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user --- StandaloneMmPkg/Library/FvLib/FvLib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/StandaloneMmPkg/Library/FvLib/FvLib.c b/StandaloneMmPkg/Librar= y/FvLib/FvLib.c index 94139ae3898b..5d5ad8f73fe0 100644 --- a/StandaloneMmPkg/Library/FvLib/FvLib.c +++ b/StandaloneMmPkg/Library/FvLib/FvLib.c @@ -359,16 +359,22 @@ FfsFindSectionData ( ParsedLength =3D 0; while (ParsedLength < FileSize) { if (Section->Type =3D=3D SectionType) { + // + // Size is 24 bits wide so mask upper 8 bits. + // + SectionLength =3D SECTION_SIZE (Section); + + if (SectionLength < sizeof (*Section)) { + return EFI_VOLUME_CORRUPTED; + } *SectionData =3D (VOID *) (Section + 1); - *SectionDataSize =3D SECTION_SIZE(Section); + *SectionDataSize =3D SectionLength - sizeof (*Section); return EFI_SUCCESS; } // - // Size is 24 bits wide so mask upper 8 bits. // SectionLength is adjusted it is 4 byte aligned. // Go to the next section // - SectionLength =3D SECTION_SIZE(Section); SectionLength =3D GET_OCCUPIED_SIZE (SectionLength, 4); =20 ParsedLength +=3D SectionLength; --=20 2.31.1 -=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 (#78891): https://edk2.groups.io/g/devel/message/78891 Mute This Topic: https://groups.io/mt/84754065/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-