From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 B127E81E07 for ; Sun, 13 Nov 2016 23:16:25 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 13 Nov 2016 23:16:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,637,1473145200"; d="scan'208";a="30922396" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 13 Nov 2016 23:16:29 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Nov 2016 23:16:29 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Nov 2016 23:16:29 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.96]) by shsmsx102.ccr.corp.intel.com ([169.254.2.239]) with mapi id 14.03.0248.002; Mon, 14 Nov 2016 15:16:26 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: Santhapur Naveen , Laszlo Ersek , "Fu, Siyuan" Thread-Topic: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet check Thread-Index: AQHSO9sXo4ndHArNnUap+q3OO9ChoaDYDhJA//99zwCAAIo/cA== Date: Mon, 14 Nov 2016 07:16:26 +0000 Message-ID: References: <1478841521-232036-1-git-send-email-jiaxin.wu@intel.com> <1478841521-232036-2-git-send-email-jiaxin.wu@intel.com> <895558F6EA4E3B41AC93A00D163B7274138B1976@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <895558F6EA4E3B41AC93A00D163B7274138B1976@SHSMSX103.ccr.corp.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 Subject: Re: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Nov 2016 07:16:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sounds good.=20 Reviewed-by: Ye Ting =20 Thanks, Ting -----Original Message----- From: Wu, Jiaxin=20 Sent: Monday, November 14, 2016 3:01 PM To: Ye, Ting ; edk2-devel@lists.01.org Cc: Santhapur Naveen ; Laszlo Ersek ; Fu, Siyuan Subject: RE: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet c= heck Hi Ting, Thanks for catch. Item 2 should be: * Replace IP4_MASK_MAX with IP4_MASK_N= UM. Item 3 is part of patch 2/2. I will correct it when I commit the patch. Thanks Jiaxin. > -----Original Message----- > From: Ye, Ting > Sent: Monday, November 14, 2016 2:52 PM > To: Wu, Jiaxin ; edk2-devel@lists.01.org > Cc: Santhapur Naveen ; Laszlo Ersek=20 > ; Fu, Siyuan > Subject: RE: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid=20 > subnet check >=20 > Hi Jiaxin, >=20 > It looks the check-in log is incorrect. > -- Any typo in item 2? > -- Is item 3 part of patch 2/2? >=20 > Please double check, thanks. >=20 > Best Regards, > Ting >=20 > -----Original Message----- > From: Wu, Jiaxin > Sent: Friday, November 11, 2016 1:19 PM > To: edk2-devel@lists.01.org > Cc: Santhapur Naveen ; Laszlo Ersek=20 > ; Ye, Ting ; Fu, Siyuan=20 > > Subject: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet=20 > check >=20 > v2: > * Separate out the return status fix. > * Replace IP4_MASK_MAX with IP4_MASK_MAX. > * Remove the ON_EXIT label. >=20 > This patch is used to add the wrong/invalid subnet check. >=20 > Cc: Santhapur Naveen > Cc: Laszlo Ersek > Cc: Ye Ting > Cc: Fu Siyuan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiaxin Wu > --- > MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 10 +++++++--- > MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c | 8 +++++--- > 2 files changed, 12 insertions(+), 6 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c > b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c > index a931bb3..5b01b35 100644 > --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c > +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c > @@ -1253,10 +1253,17 @@ Ip4Config2SetMaunualAddress ( > return EFI_WRITE_PROTECTED; > } >=20 > NewAddress =3D *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data); >=20 > + StationAddress =3D EFI_NTOHL (NewAddress.Address); SubnetMask =3D=20 > + EFI_NTOHL (NewAddress.SubnetMask); > + > + if (NetGetMaskLength (SubnetMask) =3D=3D IP4_MASK_NUM) { > + return EFI_INVALID_PARAMETER; > + } > + > // > // Store the new data, and init the DataItem status to=20 > EFI_NOT_READY because > // we may have an asynchronous configuration process. > // > Ptr =3D AllocateCopyPool (DataSize, Data); @@ -1271,13 +1278,10 @@=20 > Ip4Config2SetMaunualAddress ( >=20 > DataItem->Data.Ptr =3D Ptr; > DataItem->DataSize =3D DataSize; > DataItem->Status =3D EFI_NOT_READY; >=20 > - StationAddress =3D EFI_NTOHL (NewAddress.Address); > - SubnetMask =3D EFI_NTOHL (NewAddress.SubnetMask); > - > IpSb->Reconfig =3D TRUE; > Status =3D Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask)= ; > if (EFI_ERROR (Status)) { > goto ON_EXIT; > } > diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c > b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c > index 9cd5dd5..b0cc6a3 100644 > --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c > +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c > @@ -562,10 +562,15 @@ Ip4SetAddress ( > EFI_STATUS Status; > INTN Len; >=20 > NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE); >=20 > + Len =3D NetGetMaskLength (SubnetMask); if (Len =3D=3D IP4_MASK_NUM) { > + return EFI_INVALID_PARAMETER; > + } > + > // > // Set the ip/netmask, then compute the subnet broadcast > // and network broadcast for easy access. When computing > // nework broadcast, the subnet mask is most like longer > // than the default netmask (not subneted) as defined in @@ -573,13=20 > +578,10 @@ Ip4SetAddress ( > // networks, use the subnet's mask instead. > // > Interface->Ip =3D IpAddr; > Interface->SubnetMask =3D SubnetMask; > Interface->SubnetBrdcast =3D (IpAddr | ~SubnetMask); > - > - Len =3D NetGetMaskLength (SubnetMask); > - ASSERT (Len <=3D IP4_MASK_MAX); > Interface->NetBrdcast =3D (IpAddr | ~SubnetMask); >=20 > // > // Do clean up for Arp child > // > -- > 1.9.5.msysgit.1