From nobody Sat Nov 2 12:15:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490067798698892.3945151612228; Mon, 20 Mar 2017 20:43:18 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B0B3D80473; Mon, 20 Mar 2017 20:43:16 -0700 (PDT) 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 CB8C280472 for ; Mon, 20 Mar 2017 20:43:14 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 20 Mar 2017 20:43:14 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.110]) by fmsmga005.fm.intel.com with ESMTP; 20 Mar 2017 20:43:13 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,197,1486454400"; d="scan'208";a="78788727" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 21 Mar 2017 11:43:09 +0800 Message-Id: <1490067790-68936-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1490067790-68936-1-git-send-email-jiaxin.wu@intel.com> References: <1490067790-68936-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 1/2] MdeModulePkg/Network: Fix potential ASSERT if NetIp4IsUnicast is called X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Zhang Lubo , Wu Jiaxin , Fu Siyuan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Hegde Nagaraj P Cc: Subramanian Sriram Cc: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c | 9 ++++++--- MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 8 ++++---- MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c | 5 +++-- MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c | 4 ++-- MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c b/MdeModu= lePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c index 8eea887..c8dc697 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c @@ -1,9 +1,9 @@ /** @file Helper functions for configuring or getting the parameters relating to I= p4. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php =20 @@ -613,17 +613,20 @@ Ip4Config2ConvertIfrNvDataToConfigNvData ( CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Su= bnet Mask!", NULL); return EFI_INVALID_PARAMETER; } =20 Status =3D Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationA= ddress.v4); - if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (StationAddress.Addr= [0]), NTOHL (SubnetMask.Addr[0]))) { + if (EFI_ERROR (Status) ||=20 + (SubnetMask.Addr[0] !=3D 0 && !NetIp4IsUnicast (NTOHL (StationAddr= ess.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||=20 + !Ip4StationAddressValid (NTOHL (StationAddress.Addr[0]), NTOHL (Su= bnetMask.Addr[0]))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP= address!", NULL); return EFI_INVALID_PARAMETER; } =20 Status =3D Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.= v4); - if (EFI_ERROR (Status) || ((Gateway.Addr[0] !=3D 0) && !NetIp4IsUnicas= t (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) { + if (EFI_ERROR (Status) ||=20 + (Gateway.Addr[0] !=3D 0 && SubnetMask.Addr[0] !=3D 0 && !NetIp4IsU= nicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Ga= teway!", NULL); return EFI_INVALID_PARAMETER; } =20 Status =3D Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddre= ss, &DnsCount); diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeMod= ulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index a2583a4..5494231 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -206,11 +206,11 @@ Mtftp4OverrideValid ( CopyMem (&Ip, &Config->StationIp, sizeof (IP4_ADDR)); =20 Netmask =3D NTOHL (Netmask); Ip =3D NTOHL (Ip); =20 - if (!NetIp4IsUnicast (Gateway, Netmask) || !IP4_NET_EQUAL (Gateway, Ip= , Netmask)) { + if ((Netmask !=3D 0 && !NetIp4IsUnicast (Gateway, Netmask)) || !IP4_NE= T_EQUAL (Gateway, Ip, Netmask)) { return FALSE; } } =20 return TRUE; @@ -666,17 +666,17 @@ EfiMtftp4Configure ( Netmask =3D NTOHL (Netmask); Gateway =3D NTOHL (Gateway); ServerIp =3D NTOHL (ServerIp); =20 if (!ConfigData->UseDefaultSetting && - ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)= ))) { + ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask !=3D 0 && !NetIp4IsU= nicast (Ip, Netmask))))) { =20 return EFI_INVALID_PARAMETER; } =20 - if ((Gateway !=3D 0) && - (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !NetIp4IsUnicast (Gatewa= y, Netmask))) { + if ((Gateway !=3D 0) &&=20 + (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || (Netmask !=3D 0 && !NetI= p4IsUnicast (Gateway, Netmask)))) { =20 return EFI_INVALID_PARAMETER; } =20 OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c b/MdeModuleP= kg/Universal/Network/Tcp4Dxe/Tcp4Main.c index 8e70e01..2679f1b 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c @@ -1,9 +1,9 @@ /** @file Implementation of TCP4 protocol services. =20 -Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php
=20 @@ -181,11 +181,12 @@ Tcp4Configure ( =20 if (!TcpConfigData->AccessPoint.UseDefaultAddress) { =20 CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP= 4_ADDR)); CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof= (IP4_ADDR)); - if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || !NetIp4IsUnicast (= NTOHL (Ip), NTOHL (SubnetMask))) { + if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) ||=20 + (SubnetMask !=3D 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (Subne= tMask)))) { return EFI_INVALID_PARAMETER; } } =20 Option =3D TcpConfigData->ControlOption; diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c b/MdeModuleP= kg/Universal/Network/Udp4Dxe/Udp4Main.c index bdb79b3..d719883 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c @@ -1,9 +1,9 @@ /** @file =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php =20 @@ -170,11 +170,11 @@ Udp4Configure ( RemoteAddress =3D NTOHL (RemoteAddress); =20 =20 if (!UdpConfigData->UseDefaultAddress && (!IP4_IS_VALID_NETMASK (SubnetMask) || - !((StationAddress =3D=3D 0) || NetIp4IsUnicast (StationAddress, S= ubnetMask)) || + !((StationAddress =3D=3D 0) || (SubnetMask !=3D 0 && NetIp4IsUnic= ast (StationAddress, SubnetMask))) || IP4_IS_LOCAL_BROADCAST (RemoteAddress))) { // // Don't use default address, and subnet mask is invalid or StationA= ddress is not // a valid unicast IPv4 address or RemoteAddress is not a valid unic= ast IPv4 address // if it is not 0. diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeM= odulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index cd00f5c..259568e 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -2319,11 +2319,11 @@ EfiPxeBcSetStationIP ( } =20 if (NewStationIp !=3D NULL) { if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||=20 IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) || - (NewSubnetMask !=3D NULL && !NetIp4IsUnicast (NTOHL (NewStationIp-= >Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) { + (NewSubnetMask !=3D NULL && NewSubnetMask->Addr[0] !=3D 0 && !NetI= p4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))= )) { return EFI_INVALID_PARAMETER; } } =20 Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sat Nov 2 12:15:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 149006780041174.08673770252653; Mon, 20 Mar 2017 20:43:20 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E0EB280486; Mon, 20 Mar 2017 20:43:16 -0700 (PDT) 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 6D14180472 for ; Mon, 20 Mar 2017 20:43:16 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 20 Mar 2017 20:43:16 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.110]) by fmsmga005.fm.intel.com with ESMTP; 20 Mar 2017 20:43:14 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,197,1486454400"; d="scan'208";a="78788731" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 21 Mar 2017 11:43:10 +0800 Message-Id: <1490067790-68936-3-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1490067790-68936-1-git-send-email-jiaxin.wu@intel.com> References: <1490067790-68936-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 2/2] NetworkPkg: Fix potential ASSERT if NetIp4IsUnicast is called X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Zhang Lubo , Wu Jiaxin , Fu Siyuan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Hegde Nagaraj P Cc: Subramanian Sriram Cc: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/DnsDxe/DnsProtocol.c | 4 ++-- NetworkPkg/TcpDxe/TcpMain.c | 5 +++-- NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtoco= l.c index 6d117b2..0e7ed34 100644 --- a/NetworkPkg/DnsDxe/DnsProtocol.c +++ b/NetworkPkg/DnsDxe/DnsProtocol.c @@ -1,9 +1,9 @@ /** @file Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php =20 @@ -244,11 +244,11 @@ Dns4Configure ( =20 Ip =3D NTOHL (Ip); Netmask =3D NTOHL (Netmask); =20 if (!DnsConfigData->UseDefaultSetting && - ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)= ))) { + ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask !=3D 0 && !NetIp4IsU= nicast (Ip, Netmask))))) { Status =3D EFI_INVALID_PARAMETER; goto ON_EXIT; } =20 Status =3D Dns4CopyConfigure (&Instance->Dns4CfgData, DnsConfigData); diff --git a/NetworkPkg/TcpDxe/TcpMain.c b/NetworkPkg/TcpDxe/TcpMain.c index 03942ee..fc3713e 100644 --- a/NetworkPkg/TcpDxe/TcpMain.c +++ b/NetworkPkg/TcpDxe/TcpMain.c @@ -1,10 +1,10 @@ /** @file Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL. =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -157,11 +157,12 @@ Tcp4Configure ( =20 if (!TcpConfigData->AccessPoint.UseDefaultAddress) { =20 CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP= 4_ADDR)); CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof= (IP4_ADDR)); - if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || !NetIp4IsUnicast (= NTOHL (Ip), NTOHL (SubnetMask))) { + if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) ||=20 + (SubnetMask !=3D 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (Subne= tMask)))) { return EFI_INVALID_PARAMETER; } } =20 Option =3D TcpConfigData->ControlOption; diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/= PxeBcImpl.c index 36477e9..ab9e494 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c @@ -1083,11 +1083,12 @@ EfiPxeBcUdpWrite ( DoNotFragment =3D FALSE; } else { DoNotFragment =3D TRUE; } =20 - if (!Mode->UsingIpv6 && GatewayIp !=3D NULL && !NetIp4IsUnicast (NTOHL (= GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) { + if (!Mode->UsingIpv6 && GatewayIp !=3D NULL && Mode->SubnetMask.Addr[0] = !=3D 0 &&=20 + !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->Subnet= Mask))) { // // Gateway is provided but it's not a unicast IPv4 address, while it w= ill be ignored for IPv6. // return EFI_INVALID_PARAMETER; } @@ -2014,11 +2015,11 @@ EfiPxeBcSetStationIP ( } =20 if (!Mode->UsingIpv6 && NewStationIp !=3D NULL) { if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||=20 IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) || - (NewSubnetMask !=3D NULL && !NetIp4IsUnicast (NTOHL (NewStationIp-= >Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) { + (NewSubnetMask !=3D NULL && NewSubnetMask->Addr[0] !=3D 0 && !NetI= p4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))= )) { return EFI_INVALID_PARAMETER; } } =20 if (!Mode->Started) { --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel