From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: hao.a.wu@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Thu, 27 Jun 2019 17:54:08 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 17:54:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,425,1557212400"; d="scan'208";a="167611836" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga006.jf.intel.com with ESMTP; 27 Jun 2019 17:54:07 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 27 Jun 2019 17:54:06 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 27 Jun 2019 17:54:06 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.185]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.173]) with mapi id 14.03.0439.000; Fri, 28 Jun 2019 08:54:04 +0800 From: "Wu, Hao A" 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. Thread-Topic: [edk2-devel][Patch] MdeModulePkg/DxeCapsuleLibFmp: Add missing NULL pointer check. Thread-Index: AQHVLQUb4rLAmdXb80mKzgrzCWCqhqawPXeg Date: Fri, 28 Jun 2019 00:54:04 +0000 Message-ID: References: <20190627162629.16352-1-wei6.xu@intel.com> In-Reply-To: <20190627162629.16352-1-wei6.xu@intel.com> 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: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----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. >=20 > 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 >=20 > 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(+) >=20 > 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 ( >=20 > /** > Check the integrity of the capsule name capsule. > If the capsule is vaild, return the physical address of each capsule n= ame > string. >=20 > + 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. >=20 > @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; > + } > } >=20 > CapsuleNameBufEnd =3D CapsuleNameBufStart + CapsuleHeader- > >CapsuleImageSize - CapsuleHeader->HeaderSize; >=20 > CapsuleNamePtr =3D CapsuleNameBufStart; > -- > 2.16.2.windows.1