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.115; helo=mga14.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 4D9F62220D20A for ; Thu, 11 Jan 2018 00:01:38 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2018 00:06:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,343,1511856000"; d="scan'208";a="20716542" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 11 Jan 2018 00:06:51 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 11 Jan 2018 00:06:51 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Thu, 11 Jan 2018 16:06:50 +0800 From: "Wang, Fan" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Wu, Hao A" Thread-Topic: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). Thread-Index: AQHTirB5N7GVtYCUxU2lWGTNjfUJRqNuUMpA Date: Thu, 11 Jan 2018 08:06:49 +0000 Message-ID: References: <1515638323-13024-1-git-send-email-fan.wang@intel.com> <895558F6EA4E3B41AC93A00D163B72741635C2FD@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <895558F6EA4E3B41AC93A00D163B72741635C2FD@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 08:01:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks, Jiaxin, I will revise it. Best Regards Fan -----Original Message----- From: Wu, Jiaxin=20 Sent: Thursday, January 11, 2018 3:48 PM To: Wang, Fan ; edk2-devel@lists.01.org Cc: Fu, Siyuan ; Wu, Hao A Subject: RE: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp= 6IsNetEqual(). Hi Fan, I think we need to update the below ASSERT if apply you patch: ASSERT ((Ip1 !=3D NULL) && (Ip2 !=3D NULL) && (PrefixLength <=3D IP6_PREFI= X_MAX)); Update To:=20 ASSERT ((Ip1 !=3D NULL) && (Ip2 !=3D NULL) && (PrefixLength < IP6_PREFIX_M= AX)); If PrefixLength is IP6_PREFIX_MAX(128), then the Byte can be 16: Byte =3D (UINT8) (PrefixLength / 8); So, it will conflict with your patch ASSERT: ASSERT (Byte < 16); Thanks, Jiaxin > -----Original Message----- > From: Wang, Fan > Sent: Thursday, January 11, 2018 10:39 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan ; Wu, Jiaxin=20 > ; Wu, Hao A > Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in=20 > NetIp6IsNetEqual(). >=20 > * The library API use array elements without any index range check, this > patch is to fix this issue to avoid null pointer reference. >=20 > Cc: Fu Siyuan > Cc: Jiaxin Wu > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan > --- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index cbce28f..34e11a8 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -840,10 +840,14 @@ NetIp6IsNetEqual ( > } >=20 > if (Bit > 0) { > Mask =3D (UINT8) (0xFF << (8 - Bit)); >=20 > + ASSERT (Byte < 16); > + if (Byte >=3D 16) { > + return FALSE; > + } > if ((Ip1->Addr[Byte] & Mask) !=3D (Ip2->Addr[Byte] & Mask)) { > return FALSE; > } > } >=20 > -- > 1.9.5.msysgit.1