From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: hao.a.wu@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Thu, 27 Jun 2019 18:10:38 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 18:10:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,425,1557212400"; d="scan'208,217";a="173328525" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 27 Jun 2019 18:10:36 -0700 Received: from fmsmsx163.amr.corp.intel.com (10.18.125.72) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 27 Jun 2019 18:10:36 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx163.amr.corp.intel.com (10.18.125.72) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 27 Jun 2019 18:10:36 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.185]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.236]) with mapi id 14.03.0439.000; Fri, 28 Jun 2019 09:10:34 +0800 From: "Wu, Hao A" To: "Zhang, Chao B" , "Xu, Wei6" , "devel@edk2.groups.io" CC: "Wang, Jian J" Subject: Re: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add missing NULL pointer check. Thread-Topic: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add missing NULL pointer check. Thread-Index: AQHVLQUb4rLAmdXb80mKzgrzCWCqhqawPXeg//999YCAAIcTUA== Date: Fri, 28 Jun 2019 01:10:33 +0000 Message-ID: References: <20190627162629.16352-1-wei6.xu@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_B80AF82E9BFB8E4FBD8C89DA810C6A093C8F4F24SHSMSX104ccrcor_" --_000_B80AF82E9BFB8E4FBD8C89DA810C6A093C8F4F24SHSMSX104ccrcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Okay. Best Regards, Hao Wu From: Zhang, Chao B Sent: Friday, June 28, 2019 9:07 AM To: Wu, Hao A; Xu, Wei6; devel@edk2.groups.io Cc: Wang, Jian J Subject: RE: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add missing= NULL pointer check. HI Hao: I think the patch is to complete the security check both in info and cod= e logic to ValidateCapsuleNameCapsuleIntegrity . It is OK to keep it in one patch. From: Wu, Hao A Sent: Friday, June 28, 2019 8:54 AM To: Xu, Wei6 ; devel@edk2.groups.io Cc: Wang, Jian J ; Zhang, Chao B Subject: RE: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add missing= NULL pointer check. > -----Original Message----- > From: Xu, Wei6 > Sent: Friday, June 28, 2019 12:26 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J; Wu, Hao A; Zhang, Chao B > Subject: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add > missing NULL pointer check. > > Add missing NULL pointer check for CapsuleNameBufStart. > Also add comments to notice that capsule name integrity check assumes > the capsule has been validated by IsValidCapsuleHeader(). The patch is doing 2 things. Please help to split it into 2 commits. With this handled, Reviewed-by: Hao A Wu > Best Regards, Hao Wu > > Cc: Jian J Wang > > Cc: Hao A Wu > > Cc: Chao B Zhang > > Signed-off-by: Wei6 Xu > > --- > MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c > b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c > index 66c9be8e1f..3193ca8f4d 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c > @@ -23,10 +23,13 @@ IsCapsuleNameCapsule ( > > /** > Check the integrity of the capsule name capsule. > If the capsule is vaild, return the physical address of each capsule n= ame > string. > > + This routine assumes the capsule has been validated by > IsValidCapsuleHeader(), so > + capsule memory overflow is not going to happen in this routine. > + > @param[in] CapsuleHeader Pointer to the capsule header of a capsule > name capsule. > @param[out] CapsuleNameNum Number of capsule name. > > @retval NULL Capsule name capsule is not valid. > @retval CapsuleNameBuf Array of capsule name physical address. > @@ -63,10 +66,13 @@ ValidateCapsuleNameCapsuleIntegrity ( > // > // If strings are not aligned on a 16-bit boundary, reallocate memory = for it. > // > if (((UINTN) CapsuleNameBufStart & BIT0) !=3D 0) { > CapsuleNameBufStart =3D AllocateCopyPool (CapsuleHeader- > >CapsuleImageSize - CapsuleHeader->HeaderSize, CapsuleNameBufStart); > + if (CapsuleNameBufStart =3D=3D NULL) { > + return NULL; > + } > } > > CapsuleNameBufEnd =3D CapsuleNameBufStart + CapsuleHeader- > >CapsuleImageSize - CapsuleHeader->HeaderSize; > > CapsuleNamePtr =3D CapsuleNameBufStart; > -- > 2.16.2.windows.1 --_000_B80AF82E9BFB8E4FBD8C89DA810C6A093C8F4F24SHSMSX104ccrcor_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Okay.

 

Best Regards,

Hao Wu

 

From: Zhang, Chao B
Sent: Friday, June 28, 2019 9:07 AM
To: Wu, Hao A; Xu, Wei6; devel@edk2.groups.io
Cc: Wang, Jian J
Subject: RE: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add = missing NULL pointer check.

 

HI Hao:

   I think the pa= tch is to complete the security check both in info and code logic to ValidateCapsuleNameCapsuleIntegrity <= /span>

It is OK to keep it in one patch.=

 

 

From: Wu, Hao A
Sent: Friday, June 28, 2019 8:54 AM
To: Xu, Wei6 <wei6.xu@intel.com>; devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Zhang, Chao B <ch= ao.b.zhang@intel.com>
Subject: RE: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add = missing NULL pointer check.

 

> -----Original&nb= sp;Message-----
> From: Xu, Wei6
> Sent: Friday, June 28= , 2019 12:26 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J;&nbs= p;Wu, Hao A; Zhang, Chao B
> Subject: [edk2-devel][Patch]&nb= sp;MdeModulePkg/DxeCapsuleLibFmp: Add
> missing NULL pointer = check.

> Add missing NULL poin= ter check for CapsuleNameBufStart.
> Also add comments to&= nbsp;notice that capsule name integrity check = ;assumes
> the capsule has been&= nbsp;validated by IsValidCapsuleHeader().


The patch is doing 2 t= hings. Please help to split it into 2&nb= sp;commits.

With this handled,
Reviewed-by: Hao A Wu <<= a href=3D"mailto:hao.a.wu@intel.com">hao.a.wu@intel.com>

Best Regards,
Hao Wu



> Cc: Jian J Wang = <jian.j.wang@intel.com><= /span>
> Cc: Hao A Wu <= ;hao.a.wu@intel.com> > Cc: Chao B Zhang = ;<chao.b.zhang@intel.com&g= t;
> Signed-off-by: Wei6 Xu&nbs= p;<wei6.xu@intel.com>=
> ---
>  MdeModulePkg/Library/DxeCapsul= eLibFmp/CapsuleOnDisk.c | 6 ++++++
>  1 file changed, = ;6 insertions(+)

> diff --git a/MdeModulePkg/= Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
> b/MdeModulePkg/Library/DxeCapsuleLib= Fmp/CapsuleOnDisk.c
> index 66c9be8e1f..3193ca8f4d&nb= sp;100644
> --- a/MdeModulePkg/Library/DxeC= apsuleLibFmp/CapsuleOnDisk.c
> +++ b/MdeModulePkg/= Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
> @@ -23,10 +23,13 = @@ IsCapsuleNameCapsule (

>  /**
>    Check the&nbs= p;integrity of the capsule name capsule. >    If the c= apsule is vaild, return the physical address&= nbsp;of each capsule name
> string.

> +  This routine&n= bsp;assumes the capsule has been validated by=
> IsValidCapsuleHeader(), so
> +  capsule memory=  overflow is not going to happen in = ;this routine.
> +
>    @param[in] &n= bsp;CapsuleHeader   Pointer to the capsule&nb= sp;header of a capsule
> name capsule.
>    @param[out] C= apsuleNameNum  Number of capsule name.

>    @retval NULL&= nbsp;           &nbs= p;   Capsule name capsule is not va= lid.
>    @retval Capsu= leNameBuf      Array of capsule&nbs= p;name physical address.
> @@ -63,10 +66,13 = @@ ValidateCapsuleNameCapsuleIntegrity (
>    //
>    // If st= rings are not aligned on a 16-bit bounda= ry, reallocate memory for it.
>    //
>    if (((UINTN)&= nbsp;CapsuleNameBufStart & BIT0) !=3D 0) {
>      Capsul= eNameBufStart =3D AllocateCopyPool (CapsuleHeader- > >CapsuleImageSize - Capsu= leHeader->HeaderSize, CapsuleNameBufStart);
> +    if = ;(CapsuleNameBufStart =3D=3D NULL) {
> +     &= nbsp;return NULL;
> +    }
>    }

>    CapsuleNameBufEnd&= nbsp;=3D CapsuleNameBufStart + CapsuleHeader-
> >CapsuleImageSize - Capsu= leHeader->HeaderSize;

>    CapsuleNamePtr&nbs= p;=3D CapsuleNameBufStart;
> --
> 2.16.2.windows.1

--_000_B80AF82E9BFB8E4FBD8C89DA810C6A093C8F4F24SHSMSX104ccrcor_--