From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EC68C210C2D66 for ; Thu, 26 Jul 2018 18:33:03 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 18:33:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,407,1526367600"; d="scan'208";a="58240207" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga008.fm.intel.com with ESMTP; 26 Jul 2018 18:33:03 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Jul 2018 18:33:03 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Jul 2018 18:33:03 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.173]) with mapi id 14.03.0319.002; Fri, 27 Jul 2018 09:33:00 +0800 From: "Yao, Jiewen" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg DxeCapsuleLibFmp: Refine the code to check FmpImageSize. Thread-Index: AQHUJLKK23+NBm0Ae0+ZyFkpFbSEKqSiSg/Q Date: Fri, 27 Jul 2018 01:32:59 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503ACCE52D@shsmsx102.ccr.corp.intel.com> References: <1532590202-58060-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1532590202-58060-1-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTQ5ZDFlZGUtYWM2YS00ZmE2LWFiY2MtNTA1MGE0NDM4NzM1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVHR6Yll2bnpyeDN0V0pEa0ZJYzk2U3l6YlpyUmJoR1doazhVXC82N1BRRURXOWRZU1lUZ2VWanliT0JETGtFTncifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg DxeCapsuleLibFmp: Refine the code to check FmpImageSize. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2018 01:33:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: jiewen.yao@intel.com > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of St= ar > Zeng > Sent: Thursday, July 26, 2018 3:30 PM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen ; Zeng, Star > Subject: [edk2] [PATCH] MdeModulePkg DxeCapsuleLibFmp: Refine the code to > check FmpImageSize. >=20 > The code to check FmpImageSize again OFFSET_OF > (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, > UpdateHardwareInstance) > can be refined to check against FmpImageHeaderSize. >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > index a1347b5ce67c..ee3adce2a2f2 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > @@ -268,10 +268,6 @@ ValidateFmpCapsule ( > } > FmpImageSize =3D (UINTN)EndOfPayload - ItemOffsetList[Index]; >=20 > - if (FmpImageSize < > OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, > UpdateHardwareInstance)) { > - DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) < > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER\n", > FmpImageSize)); > - return EFI_INVALID_PARAMETER; > - } > FmpImageHeaderSize =3D > sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER); > if ((ImageHeader->Version > > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) || > (ImageHeader->Version < 1)) { > @@ -281,6 +277,10 @@ ValidateFmpCapsule ( > if (ImageHeader->Version < > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) { > FmpImageHeaderSize =3D > OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, > UpdateHardwareInstance); > } > + if (FmpImageSize < FmpImageHeaderSize) { > + DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) < > FmpImageHeaderSize(0x%x)\n", FmpImageSize, FmpImageHeaderSize)); > + return EFI_INVALID_PARAMETER; > + } >=20 > // No overflow > if (FmpImageSize !=3D (UINT64)FmpImageHeaderSize + > (UINT64)ImageHeader->UpdateImageSize + > (UINT64)ImageHeader->UpdateVendorCodeSize) { > -- > 2.7.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel