From nobody Sat Jul 12 07:01:47 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 151503606715547.91096551037958; Wed, 3 Jan 2018 19:21:07 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DE9BB222D1550; Wed, 3 Jan 2018 19:15:59 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 BB569222D154D for ; Wed, 3 Jan 2018 19:15:57 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 19:20:30 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga001.jf.intel.com with ESMTP; 03 Jan 2018 19:20:29 -0800 X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,505,1508828400"; d="scan'208";a="21245843" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 4 Jan 2018 11:20:08 +0800 Message-Id: <1515036008-10700-5-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515036008-10700-1-git-send-email-fan.wang@intel.com> References: <1515036008-10700-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 4/4] NetworkPkg: Add more parameter or return status check in UDP6 driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu 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" From: Wang Fan In UDP6Dxe, there are several places that may be enhanced to check input parameters and returned status. This patch is to fix these issues. Cc: Ye Ting Cc: Jiaxin Wu Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Udp6Dxe/Udp6Driver.c | 48 +++++++++++++++++++++++--------------= ---- NetworkPkg/Udp6Dxe/Udp6Impl.c | 17 +++++++++++++++ NetworkPkg/Udp6Dxe/Udp6Main.c | 2 +- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Drive= r.c index 6dde1fc..f9d528e 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Driver.c +++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c @@ -288,22 +288,19 @@ Udp6DriverBindingStop ( Udp6DestroyChildEntryInHandleBuffer, &Context, NULL ); } else if (IsListEmpty (&Udp6Service->ChildrenList)) { - gBS->UninstallMultipleProtocolInterfaces ( - NicHandle, - &gEfiUdp6ServiceBindingProtocolGuid, - &Udp6Service->ServiceBinding, - NULL - ); + Status =3D gBS->UninstallMultipleProtocolInterfaces ( + NicHandle, + &gEfiUdp6ServiceBindingProtocolGuid, + &Udp6Service->ServiceBinding, + NULL + ); =20 Udp6CleanService (Udp6Service); - FreePool (Udp6Service); - - Status =3D EFI_SUCCESS; } =20 return Status; } =20 @@ -508,25 +505,34 @@ Udp6ServiceBindingDestroyChild ( Instance->InDestroy =3D TRUE; =20 // // Close the Ip6 protocol on the default IpIo. // - gBS->CloseProtocol ( - Udp6Service->IpIo->ChildHandle, - &gEfiIp6ProtocolGuid, - gUdp6DriverBinding.DriverBindingHandle, - Instance->ChildHandle - ); + Status =3D gBS->CloseProtocol ( + Udp6Service->IpIo->ChildHandle, + &gEfiIp6ProtocolGuid, + gUdp6DriverBinding.DriverBindingHandle, + Instance->ChildHandle + ); + if (EFI_ERROR (Status)) { + Instance->InDestroy =3D FALSE; + return Status; + } + // // Close the Ip6 protocol on this instance's IpInfo. // - gBS->CloseProtocol ( - Instance->IpInfo->ChildHandle, - &gEfiIp6ProtocolGuid, - gUdp6DriverBinding.DriverBindingHandle, - Instance->ChildHandle - ); + Status =3D gBS->CloseProtocol ( + Instance->IpInfo->ChildHandle, + &gEfiIp6ProtocolGuid, + gUdp6DriverBinding.DriverBindingHandle, + Instance->ChildHandle + ); + if (EFI_ERROR (Status)) { + Instance->InDestroy =3D FALSE; + return Status; + } =20 // // Uninstall the Udp6Protocol previously installed on the ChildHandle. // Status =3D gBS->UninstallMultipleProtocolInterfaces ( diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c index 458470c..d014e2d 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Impl.c +++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c @@ -55,10 +55,13 @@ Udp6FindInstanceByPort ( /** This function is the packet transmitting notify function registered to t= he IpIo interface. It's called to signal the udp TxToken when the IpIo layer com= pletes transmitting of the udp datagram. =20 + If Context is NULL, then ASSERT(). + If NotifyData is NULL, then ASSERT(). + @param[in] Status The completion status of the output udp da= tagram. @param[in] Context Pointer to the context data. @param[in] Sender Specify a EFI_IP6_PROTOCOL for sending. @param[in] NotifyData Pointer to the notify data. =20 @@ -73,10 +76,14 @@ Udp6DgramSent ( ); =20 /** This function processes the received datagram passed up by the IpIo laye= r. =20 + If NetSession is NULL, then ASSERT(). + If Packet is NULL, then ASSERT(). + If Context is NULL, then ASSERT(). + @param[in] Status The status of this udp datagram. @param[in] IcmpError The IcmpError code, only available when St= atus is EFI_ICMP_ERROR. @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA. @param[in] Packet Pointer to the NET_BUF containing the rece= ived udp @@ -975,10 +982,13 @@ Udp6RemoveToken ( /** This function is the packet transmitting notify function registered to t= he IpIo interface. It's called to signal the udp TxToken when IpIo layer complet= es the transmitting of the udp datagram. =20 + If Context is NULL, then ASSERT(). + If NotifyData is NULL, then ASSERT(). + @param[in] Status The completion status of the output udp da= tagram. @param[in] Context Pointer to the context data. @param[in] Sender Specify a EFI_IP6_PROTOCOL for sending. @param[in] NotifyData Pointer to the notify data. =20 @@ -993,10 +1003,12 @@ Udp6DgramSent ( ) { UDP6_INSTANCE_DATA *Instance; EFI_UDP6_COMPLETION_TOKEN *Token; =20 + ASSERT (Context !=3D NULL && NotifyData !=3D NULL); + Instance =3D (UDP6_INSTANCE_DATA *) Context; Token =3D (EFI_UDP6_COMPLETION_TOKEN *) NotifyData; =20 if (Udp6RemoveToken (&Instance->TxTokens, Token) =3D=3D EFI_SUCCESS) { // @@ -1010,10 +1022,14 @@ Udp6DgramSent ( =20 =20 /** This function processes the received datagram passed up by the IpIo laye= r. =20 + If NetSession is NULL, then ASSERT(). + If Packet is NULL, then ASSERT(). + If Context is NULL, then ASSERT(). + @param[in] Status The status of this udp datagram. @param[in] IcmpError The IcmpError code, only available when St= atus is EFI_ICMP_ERROR. @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA. @param[in] Packet Pointer to the NET_BUF containing the rece= ived udp @@ -1029,10 +1045,11 @@ Udp6DgramRcvd ( IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context ) { + ASSERT (NetSession !=3D NULL && Packet !=3D NULL && Context !=3D NULL); NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE); =20 // // IpIo only passes received packets with Status EFI_SUCCESS or EFI_ICMP= _ERROR. // diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index 53145c3..1d7f0ac 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -379,11 +379,11 @@ Udp6Groups ( if (JoinFlag) { =20 Status =3D NetMapInsertTail (&Instance->McastIps, (VOID *) McastIp, NU= LL); } else { =20 - NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, MulticastAddress); + Status =3D NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, Multica= stAddress); } =20 ON_EXIT: =20 gBS->RestoreTPL (OldTpl); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel