From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4AD041A1DEB for ; Thu, 27 Oct 2016 19:52:44 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP; 27 Oct 2016 19:52:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,407,1473145200"; d="scan'208";a="24658205" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 27 Oct 2016 19:52:43 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 27 Oct 2016 19:52:43 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 27 Oct 2016 19:52:43 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.139]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Fri, 28 Oct 2016 10:52:40 +0800 From: "Wu, Jiaxin" To: "Fu, Siyuan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Zhang, Lubo" Thread-Topic: [edk2] [PATCH v2 3/3] NetworkPkg: Update IP4 stack drivers for classless address unicast check. Thread-Index: AQHSMEAwX2tUZORkoUiwzECyRhvlXaC9KzxA Date: Fri, 28 Oct 2016 02:52:39 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B72741389FE86@SHSMSX103.ccr.corp.intel.com> References: <1477565499-11764-1-git-send-email-siyuan.fu@intel.com> <1477565499-11764-4-git-send-email-siyuan.fu@intel.com> In-Reply-To: <1477565499-11764-4-git-send-email-siyuan.fu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmEwYTNhYjAtMmZiZC00OWYwLTk4YWYtYTkwYzE1ZmU3MWM0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS45LjYuNiIsIlRydXN0ZWRMYWJlbEhhc2giOiJaMGNXQkZMeE9kTnVyXC96Tm9cLzVlRm5QbGVYMVlaRHBBY0NFdStiakpZSkE9In0= x-ctpclassification: CTP_PUBLIC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 3/3] NetworkPkg: Update IP4 stack drivers for classless address unicast 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: Fri, 28 Oct 2016 02:52:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-By: Wu Jiaxin Best Regards! Jiaxin > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fu > Siyuan > Sent: Thursday, October 27, 2016 6:52 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Zhang, Lubo ; Wu, > Jiaxin > Subject: [edk2] [PATCH v2 3/3] NetworkPkg: Update IP4 stack drivers for > classless address unicast check. >=20 > V2 update: > Keep the zero address and broadcast check if network mask is not availabl= e. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan > Cc: Ye Ting > Cc: Zhang Lubo > Cc: Wu Jiaxin > --- > NetworkPkg/IScsiDxe/IScsiConfig.c | 16 ++++++++++---- > NetworkPkg/TcpDxe/TcpMain.c | 6 ++--- > NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 40 +++++++++++++++++++++++---- > ------- > NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 4 +++- > 4 files changed, 45 insertions(+), 21 deletions(-) >=20 > diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c > b/NetworkPkg/IScsiDxe/IScsiConfig.c > index 16a90a6..57571ad 100644 > --- a/NetworkPkg/IScsiDxe/IScsiConfig.c > +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c > @@ -164,7 +164,10 @@ IpIsUnicast ( > ) > { > if (IpMode =3D=3D IP_MODE_IP4) { > - return NetIp4IsUnicast (NTOHL (Ip->Addr[0]), 0); > + if (IP4_IS_UNSPECIFIED (NTOHL (Ip->Addr[0])) || > IP4_IS_LOCAL_BROADCAST (NTOHL (Ip->Addr[0]))) { > + return FALSE; > + } > + return TRUE; > } else if (IpMode =3D=3D IP_MODE_IP6) { > return NetIp6IsValidUnicast (&Ip->v6); > } else { > @@ -2349,7 +2352,9 @@ IScsiFormCallback ( >=20 > case KEY_LOCAL_IP: > Status =3D NetLibStrToIp4 (IfrNvData->LocalIp, &HostIp.v4); > - if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0])= , 0)) { > + if (EFI_ERROR (Status) || > + ((Private->Current->SessionConfigData.SubnetMask.Addr[0] !=3D = 0) && > + !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), > + NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr))) > + ) { > CreatePopUp ( > EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > &Key, > @@ -2383,7 +2388,10 @@ IScsiFormCallback ( >=20 > case KEY_GATE_WAY: > Status =3D NetLibStrToIp4 (IfrNvData->Gateway, &Gateway.v4); > - if (EFI_ERROR (Status) || ((Gateway.Addr[0] !=3D 0) && !NetIp4IsUn= icast > (NTOHL (Gateway.Addr[0]), 0))) { > + if (EFI_ERROR (Status) || > + ((Gateway.Addr[0] !=3D 0) && > + (Private->Current->SessionConfigData.SubnetMask.Addr[0] !=3D = 0) && > + !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), > + NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr))) > + ) { > CreatePopUp ( > EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > &Key, > @@ -2400,7 +2408,7 @@ IScsiFormCallback ( > case KEY_TARGET_IP: > UnicodeStrToAsciiStrS (IfrNvData->TargetIp, IpString, sizeof (IpSt= ring)); > Status =3D IScsiAsciiStrToIp (IpString, IfrNvData->IpMode, &HostIp= ); > - if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, IfrNvData->IpMode= )) { > + if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST > + (EFI_NTOHL(HostIp.v4)) || IP4_IS_UNSPECIFIED (EFI_NTOHL(HostIp.v4))) { > CreatePopUp ( > EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > &Key, > diff --git a/NetworkPkg/TcpDxe/TcpMain.c b/NetworkPkg/TcpDxe/TcpMain.c > index 96a295a..03942ee 100644 > --- a/NetworkPkg/TcpDxe/TcpMain.c > +++ b/NetworkPkg/TcpDxe/TcpMain.c > @@ -147,10 +147,10 @@ Tcp4Configure ( > if (NULL !=3D TcpConfigData) { >=20 > CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof > (IP4_ADDR)); > - if ((Ip !=3D 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) { > + if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) { > return EFI_INVALID_PARAMETER; > } > - > + > if (TcpConfigData->AccessPoint.ActiveFlag && (0 =3D=3D TcpConfigData= - > >AccessPoint.RemotePort || (Ip =3D=3D 0))) { > return EFI_INVALID_PARAMETER; > } > @@ -159,7 +159,7 @@ Tcp4Configure ( >=20 > CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof > (IP4_ADDR)); > CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, > sizeof (IP4_ADDR)); > - if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTO= HL > (SubnetMask))) { > + if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || > + !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask))) { > return EFI_INVALID_PARAMETER; > } > } > diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c > b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c > index c7c5bd6..52095c5 100644 > --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c > +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c > @@ -856,8 +856,7 @@ EfiPxeBcMtftp ( > (BufferSize =3D=3D NULL) || > (ServerIp =3D=3D NULL) || > ((BufferPtr =3D=3D NULL) && DontUseBuffer) || > - ((BlockSize !=3D NULL) && (*BlockSize < PXE_MTFTP_DEFAULT_BLOCK_SI= ZE)) > || > - (!NetIp4IsUnicast (NTOHL (ServerIp->Addr[0]), 0) && !NetIp6IsValid= Unicast > (&ServerIp->v6))) { > + ((BlockSize !=3D NULL) && (*BlockSize < > + PXE_MTFTP_DEFAULT_BLOCK_SIZE))) { > return EFI_INVALID_PARAMETER; > } >=20 > @@ -867,6 +866,16 @@ EfiPxeBcMtftp ( > Mode =3D Private->PxeBc.Mode; >=20 > if (Mode->UsingIpv6) { > + if (!NetIp6IsValidUnicast (&ServerIp->v6)) { > + return EFI_INVALID_PARAMETER; > + } > + } else { > + if (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || > IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0]))) { > + return EFI_INVALID_PARAMETER; > + } > + } > + > + if (Mode->UsingIpv6) { > // > // Set configuration data for Mtftp6 instance. > // > @@ -1076,7 +1085,7 @@ EfiPxeBcUdpWrite ( > DoNotFragment =3D TRUE; > } >=20 > - if (!Mode->UsingIpv6 && GatewayIp !=3D NULL && !NetIp4IsUnicast (NTOHL > (GatewayIp->Addr[0]), 0)) { > + if (!Mode->UsingIpv6 && GatewayIp !=3D NULL && !NetIp4IsUnicast (NTOHL > + (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) { > // > // Gateway is provided but it's not a unicast IPv4 address, while it= will be > ignored for IPv6. > // > @@ -1587,13 +1596,16 @@ EfiPxeBcSetIpFilter ( > // > return EFI_INVALID_PARAMETER; > } > - if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != =3D 0 > && > - (NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) || > - NetIp6IsValidUnicast (&NewFilter->IpList[Index].v6))) { > - // > - // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IPv4/IPv6 > address > - // is in IpList, promiscuous mode is needed. > - // > + if (Mode->UsingIpv6) { > + if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) = !=3D 0 > && > + NetIp6IsValidUnicast (&NewFilter->IpList[Index].v6)) { > + NeedPromiscuous =3D TRUE; > + } > + } else if ((EFI_NTOHL(Mode->StationIp) !=3D 0) && > + (EFI_NTOHL(Mode->SubnetMask) !=3D 0) && > + IP4_NET_EQUAL(EFI_NTOHL(Mode->StationIp), > EFI_NTOHL(NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask.v4)) > && > + NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), > EFI_NTOHL(Mode->SubnetMask)) && > + ((NewFilter->Filters & > + EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) !=3D 0)) { > NeedPromiscuous =3D TRUE; > } > } > @@ -1987,9 +1999,7 @@ EfiPxeBcSetStationIP ( > return EFI_INVALID_PARAMETER; > } >=20 > - if (NewStationIp !=3D NULL && > - (!NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0) && > - !NetIp6IsValidUnicast (&NewStationIp->v6))) { > + if (NewStationIp !=3D NULL && !NetIp6IsValidUnicast > + (&NewStationIp->v6)) { > return EFI_INVALID_PARAMETER; > } >=20 > @@ -2003,6 +2013,10 @@ EfiPxeBcSetStationIP ( > return EFI_INVALID_PARAMETER; > } >=20 > + if (!Mode->UsingIpv6 && NewStationIp !=3D NULL && !NetIp4IsUnicast (NT= OHL > (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))) { > + return EFI_INVALID_PARAMETER; > + } > + > if (!Mode->Started) { > return EFI_NOT_STARTED; > } > diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c > b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c > index 3ea9518..00c652d 100644 > --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c > +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c > @@ -258,7 +258,9 @@ PxeBcIcmpErrorDpcHandle ( > } >=20 > if (EFI_IP4 (RxData->Header->SourceAddress) !=3D 0 && > - !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { > + (NTOHL (Mode->SubnetMask.Addr[0]) !=3D 0) && > + IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData- > >Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) && > + !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), > + NTOHL (Mode->SubnetMask.Addr[0]))) { > // > // The source address of the received packet should be a valid unica= st > address. > // > -- > 2.7.4.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel