From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 75EB281E04 for ; Sun, 13 Nov 2016 23:00:57 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 13 Nov 2016 23:01:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,637,1473145200"; d="scan'208";a="30931949" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 13 Nov 2016 23:01:01 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Nov 2016 23:01:01 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Nov 2016 23:01:00 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.96]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.138]) with mapi id 14.03.0248.002; Mon, 14 Nov 2016 15:00:58 +0800 From: "Wu, Jiaxin" To: "Ye, Ting" , "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: AQHSPkOJQE1STqc3SEiWV3OPZmvoRqDYDAfA Date: Mon, 14 Nov 2016 07:00:58 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274138B1976@SHSMSX103.ccr.corp.intel.com> References: <1478841521-232036-1-git-send-email-jiaxin.wu@intel.com> <1478841521-232036-2-git-send-email-jiaxin.wu@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjdhNWE5YjAtNTM4Mi00YmE4LWJkM2UtMzNmYzEyZjUzMDUwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Imo1VWllRGdDR1E2aVVTYU9WSUU1UFRIb1lRXC9tTUt4dmczV01CZERhY2trPSJ9 x-ctpclassification: CTP_IC 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:00:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 > ; Fu, Siyuan > Subject: RE: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid 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 > ; Ye, Ting ; Fu, Siyuan > > Subject: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet > 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 > + 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 EFI_NOT_READY > because > // we may have an asynchronous configuration process. > // > Ptr =3D AllocateCopyPool (DataSize, Data); @@ -1271,13 +1278,10 @@ > 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 +5= 78,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