From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 86284208F7A23 for ; Thu, 21 Dec 2017 00:44:53 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2017 00:49:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,435,1508828400"; d="scan'208";a="3665882" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 21 Dec 2017 00:49:41 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Dec 2017 00:49:41 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Thu, 21 Dec 2017 16:47:31 +0800 From: "Wu, Jiaxin" To: "Fu, Siyuan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Wang, Fan" Thread-Topic: [edk2] [Patch] MdeModulePkg/IpIoLib: add more error handling code to DxeIpIoLib. Thread-Index: AQHTc+EY6UmDbcKG5UG/pGHVwYetdqNNiNHw Date: Thu, 21 Dec 2017 08:47:30 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B727416355ADB@SHSMSX103.ccr.corp.intel.com> References: <20171213070654.16888-1-siyuan.fu@intel.com> In-Reply-To: <20171213070654.16888-1-siyuan.fu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDExMTM2ZGQtNzZlYy00ZjJlLTg2N2EtOWE5MDY2ZGQ3ZGQ5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IklmakdwS3Y3aDhPSk5tTEo2TTVRaUNaVFFLdlRYQ0I0aFNwVFR0VUI2Sm89In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/IpIoLib: add more error handling code to DxeIpIoLib. 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: , X-List-Received-Date: Thu, 21 Dec 2017 08:44:53 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiaxin Wu > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fu= , > Siyuan > Sent: Wednesday, December 13, 2017 3:07 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Wang, Fan ; Wu, > Jiaxin > Subject: [edk2] [Patch] MdeModulePkg/IpIoLib: add more error handling > code to DxeIpIoLib. >=20 > In DxeIpIo, there are several places not check the returned value of call= ed > functions. > This patch is to add the error handling to these functions. >=20 > Cc: Ye Ting > Cc: Wu Jiaxin > Cc: Wang Fan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan > --- > MdeModulePkg/Include/Library/IpIoLib.h | 4 +- > MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c | 83 > +++++++++++++++++----------- > 2 files changed, 54 insertions(+), 33 deletions(-) >=20 > diff --git a/MdeModulePkg/Include/Library/IpIoLib.h > b/MdeModulePkg/Include/Library/IpIoLib.h > index aab0c68059..a8496f729d 100644 > --- a/MdeModulePkg/Include/Library/IpIoLib.h > +++ b/MdeModulePkg/Include/Library/IpIoLib.h > @@ -2,7 +2,7 @@ > This library is only intended to be used by UEFI network stack modules= . > It provides the combined IpIo layer on the EFI IP4 Protocol and EFI IP= 6 > protocol. >=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 that accompanies this > distribution. > The full text of the license may be found at > @@ -426,7 +426,7 @@ IpIoSend ( > IN IP_IO_IP_INFO *Sender OPTIONAL, > IN VOID *Context OPTIONAL, > IN VOID *NotifyData OPTIONAL, > - IN EFI_IP_ADDRESS *Dest, > + IN EFI_IP_ADDRESS *Dest OPTIONAL, > IN IP_IO_OVERRIDE *OverrideData OPTIONAL > ); >=20 > diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c > b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c > index abc07fb0ff..6f312cccb2 100644 > --- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c > +++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c > @@ -2,7 +2,7 @@ > IpIo Library. >=20 > (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
> -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 BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at > @@ -234,24 +234,25 @@ IpIoCloseProtocolDestroyIpChild ( > // > // Close the previously openned IP protocol. > // > - gBS->CloseProtocol ( > - ChildHandle, > - IpProtocolGuid, > - ImageHandle, > - ControllerHandle > - ); > + Status =3D gBS->CloseProtocol ( > + ChildHandle, > + IpProtocolGuid, > + ImageHandle, > + ControllerHandle > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } >=20 > // > // Destroy the IP child. > // > - Status =3D NetLibDestroyServiceChild ( > - ControllerHandle, > - ImageHandle, > - ServiceBindingGuid, > - ChildHandle > - ); > - > - return Status; > + return NetLibDestroyServiceChild ( > + ControllerHandle, > + ImageHandle, > + ServiceBindingGuid, > + ChildHandle > + ); > } >=20 > /** > @@ -377,8 +378,14 @@ IpIoIcmpv4Handler ( > TrimBytes =3D (UINT32) (PayLoadHdr - (UINT8 *) IcmpHdr); >=20 > NetbufTrim (Pkt, TrimBytes, TRUE); > - > - IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo- > >RcvdContext); > + > + // > + // If the input packet has invalid format, and TrimBytes is larger tha= n > + // the packet size, the NetbufTrim might trim the packet to zero. > + // > + if (Pkt->TotalSize !=3D 0) { > + IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo- > >RcvdContext); > + } >=20 > return EFI_SUCCESS; > } > @@ -539,7 +546,13 @@ IpIoIcmpv6Handler ( >=20 > NetbufTrim (Pkt, TrimBytes, TRUE); >=20 > - IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo- > >RcvdContext); > + // > + // If the input packet has invalid format, and TrimBytes is larger tha= n > + // the packet size, the NetbufTrim might trim the packet to zero. > + // > + if (Pkt->TotalSize !=3D 0) { > + IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo- > >RcvdContext); > + } >=20 > return EFI_SUCCESS; > } > @@ -1540,7 +1553,7 @@ IpIoSend ( > IN IP_IO_IP_INFO *Sender OPTIONAL, > IN VOID *Context OPTIONAL, > IN VOID *NotifyData OPTIONAL, > - IN EFI_IP_ADDRESS *Dest, > + IN EFI_IP_ADDRESS *Dest OPTIONAL, > IN IP_IO_OVERRIDE *OverrideData OPTIONAL > ) > { > @@ -1791,7 +1804,7 @@ IpIoConfigIp ( > } >=20 > if (IpConfigData !=3D NULL) { > - if (IpInfo->IpVersion =3D=3D IP_VERSION_4){ > + if (IpInfo->IpVersion =3D=3D IP_VERSION_4) { >=20 > if (((EFI_IP4_CONFIG_DATA *) IpConfigData)->UseDefaultAddress) { > Ip.Ip4->GetModeData ( > @@ -1800,10 +1813,14 @@ IpIoConfigIp ( > NULL, > NULL > ); > + if (EFI_ERROR (Status)) { > + Ip.Ip4->Configure (Ip.Ip4, NULL); > + goto OnExit; > + } >=20 > IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)- > >StationAddress, &Ip4ModeData.ConfigData.StationAddress); > IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)- > >SubnetMask, &Ip4ModeData.ConfigData.SubnetMask); > - } > + } >=20 > CopyMem ( > &IpInfo->Addr.Addr, > @@ -1820,16 +1837,20 @@ IpIoConfigIp ( > Ip.Ip4, > &IpInfo->DummyRcvToken.Ip4Token > ); > - if (EFI_ERROR (Status)) { > - Ip.Ip4->Configure (Ip.Ip4, NULL); > - } > - } else { > - Ip.Ip6->GetModeData ( > - Ip.Ip6, > - &Ip6ModeData, > - NULL, > - NULL > - ); > + if (EFI_ERROR (Status)) { > + Ip.Ip4->Configure (Ip.Ip4, NULL); > + } > + } else { > + Ip.Ip6->GetModeData ( > + Ip.Ip6, > + &Ip6ModeData, > + NULL, > + NULL > + ); > + if (EFI_ERROR (Status)) { > + Ip.Ip6->Configure (Ip.Ip6, NULL); > + goto OnExit; > + } >=20 > if (Ip6ModeData.IsConfigured) { > CopyMem ( > -- > 2.13.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel