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 4DE4981E04 for ; Sun, 13 Nov 2016 22:51:32 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 13 Nov 2016 22:51:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,488,1473145200"; d="scan'208";a="786084041" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 13 Nov 2016 22:51:36 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Nov 2016 22:51:36 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Nov 2016 22:51:35 -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 14:51:33 +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 Date: Mon, 14 Nov 2016 06:51:33 +0000 Message-ID: References: <1478841521-232036-1-git-send-email-jiaxin.wu@intel.com> <1478841521-232036-2-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1478841521-232036-2-git-send-email-jiaxin.wu@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 06:51:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jiaxin, It looks the check-in log is incorrect.=20 -- Any typo in item 2? -- Is item 3 part of patch 2/2?=20 Please double check, thanks. Best Regards, Ting -----Original Message----- From: Wu, Jiaxin=20 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 v2: * Separate out the return status fix. * Replace IP4_MASK_MAX with IP4_MASK_MAX. * Remove the ON_EXIT label. This patch is used to add the wrong/invalid subnet check. 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(-) diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeMo= dulePkg/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 EFI_NOT_READY bec= ause // we may have an asynchronous configuration process. // Ptr =3D AllocateCopyPool (DataSize, Data); @@ -1271,13 +1278,10 @@ Ip4Co= nfig2SetMaunualAddress ( =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/U= niversal/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 +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