From nobody Fri Dec 27 01:45:06 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.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 1501479658248807.048695200501; Sun, 30 Jul 2017 22:40:58 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 77F0C21E1DB53; Sun, 30 Jul 2017 22:38:36 -0700 (PDT) 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 4854D21E1DB4D for ; Sun, 30 Jul 2017 22:38:33 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2017 22:40:41 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.74]) by orsmga003.jf.intel.com with ESMTP; 30 Jul 2017 22:40:39 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,440,1496127600"; d="scan'208";a="999009362" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Mon, 31 Jul 2017 13:40:36 +0800 Message-Id: <1501479637-42288-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1501479637-42288-1-git-send-email-jiaxin.wu@intel.com> References: <1501479637-42288-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 1/2] CryptoPkg/TlsLib: Remove the redundant free of BIO objects 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 , Wu Jiaxin , Long Qin 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" TLS BIO objects (InBio/OutBio) will be freed by SSL_free() function. So, the following free operation (BIO_free) in TlsFree is redundant. It can be removed directly. Cc: Ye Ting Cc: Long Qin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Fu Siyuan Reviewed-by: Long Qin --- CryptoPkg/Library/TlsLib/TlsInit.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/CryptoPkg/Library/TlsLib/TlsInit.c b/CryptoPkg/Library/TlsLib/= TlsInit.c index e2c9744..e524647 100644 --- a/CryptoPkg/Library/TlsLib/TlsInit.c +++ b/CryptoPkg/Library/TlsLib/TlsInit.c @@ -128,24 +128,16 @@ TlsFree ( if (TlsConn =3D=3D NULL) { return; } =20 // - // Free the internal TLS and BIO objects. + // Free the internal TLS and related BIO objects. // if (TlsConn->Ssl !=3D NULL) { SSL_free (TlsConn->Ssl); } =20 - if (TlsConn->InBio !=3D NULL) { - BIO_free (TlsConn->InBio); - } - - if (TlsConn->OutBio !=3D NULL) { - BIO_free (TlsConn->OutBio); - } - OPENSSL_free (Tls); } =20 /** Create a new TLS object for a connection. --=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 Fri Dec 27 01:45:06 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.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 1501479661449178.6271011751478; Sun, 30 Jul 2017 22:41:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B23D821E1DB56; Sun, 30 Jul 2017 22:38:36 -0700 (PDT) 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 9538821E1DB4D for ; Sun, 30 Jul 2017 22:38:34 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2017 22:40:42 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.74]) by orsmga003.jf.intel.com with ESMTP; 30 Jul 2017 22:40:41 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,440,1496127600"; d="scan'208";a="999009366" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Mon, 31 Jul 2017 13:40:37 +0800 Message-Id: <1501479637-42288-3-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1501479637-42288-1-git-send-email-jiaxin.wu@intel.com> References: <1501479637-42288-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 2/2] NetworkPkg/HttpDxe: Destroy the TLS instance when cleaning up the HTTP child 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 , Fu Siyuan , Wu Jiaxin 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" During clean up the HTTP child, all resources used by it should be cleaned.= But currently, TLS instance is not destroyed. This patch is to fix this issue. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Fu Siyuan --- NetworkPkg/HttpDxe/HttpImpl.c | 1 + NetworkPkg/HttpDxe/HttpProto.c | 7 +++++++ NetworkPkg/HttpDxe/HttpProto.h | 3 ++- NetworkPkg/HttpDxe/HttpsSupport.c | 14 +++++++------- NetworkPkg/HttpDxe/HttpsSupport.h | 4 +++- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 1f7a4fa..9570053 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -378,10 +378,11 @@ EfiHttpRequest ( ImageHandle =3D HttpInstance->Service->Ip4DriverBindingHandle; } =20 HttpInstance->TlsChildHandle =3D TlsCreateChild ( ImageHandle, + &(HttpInstance->TlsSb), &(HttpInstance->Tls), &(HttpInstance->TlsConfiguration) ); if (HttpInstance->TlsChildHandle =3D=3D NULL) { return EFI_DEVICE_ERROR; diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 3fda294..ab00f3d 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -862,10 +862,17 @@ HttpCleanProtocol ( } =20 NetMapClean (&HttpInstance->TxTokens); NetMapClean (&HttpInstance->RxTokens); =20 + if (HttpInstance->TlsSb !=3D NULL && HttpInstance->TlsChildHandle !=3D N= ULL) { + // + // Destroy the TLS instance. =20 + // + HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, HttpInstance->= TlsChildHandle); + } + if (HttpInstance->Tcp4ChildHandle !=3D NULL) { gBS->CloseProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, HttpInstance->Service->Ip4DriverBindingHandle, diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index 95fb484..04d36aa 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -164,11 +164,12 @@ typedef struct _HTTP_PROTOCOL { =20 // // Https Support // BOOLEAN UseHttps; - =20 + + EFI_SERVICE_BINDING_PROTOCOL *TlsSb; EFI_HANDLE TlsChildHandle; /// Tls ChildHandle TLS_CONFIG_DATA TlsConfigData; EFI_TLS_PROTOCOL *Tls; EFI_TLS_CONFIGURATION_PROTOCOL *TlsConfiguration; EFI_TLS_SESSION_STATE TlsSessionState; diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c b/NetworkPkg/HttpDxe/HttpsSu= pport.c index e4d9a37..e6f4d5a 100644 --- a/NetworkPkg/HttpDxe/HttpsSupport.c +++ b/NetworkPkg/HttpDxe/HttpsSupport.c @@ -138,44 +138,44 @@ IsHttpsUrl ( =20 /** Creates a Tls child handle, open EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURAT= ION_PROTOCOL. =20 @param[in] ImageHandle The firmware allocated handle for the = UEFI image. + @param[out] TlsSb Pointer to the TLS SERVICE_BINDING_PRO= TOCOL. @param[out] TlsProto Pointer to the EFI_TLS_PROTOCOL instan= ce. @param[out] TlsConfiguration Pointer to the EFI_TLS_CONFIGURATION_P= ROTOCOL instance. =20 @return The child handle with opened EFI_TLS_PROTOCOL and EFI_TLS_CONFI= GURATION_PROTOCOL. =20 **/ EFI_HANDLE EFIAPI TlsCreateChild ( IN EFI_HANDLE ImageHandle, + OUT EFI_SERVICE_BINDING_PROTOCOL **TlsSb, OUT EFI_TLS_PROTOCOL **TlsProto, OUT EFI_TLS_CONFIGURATION_PROTOCOL **TlsConfiguration ) { EFI_STATUS Status; - EFI_SERVICE_BINDING_PROTOCOL *TlsSb; EFI_HANDLE TlsChildHandle; =20 - TlsSb =3D NULL; TlsChildHandle =3D 0; =20 // // Locate TlsServiceBinding protocol. // gBS->LocateProtocol ( &gEfiTlsServiceBindingProtocolGuid, NULL, - (VOID **) &TlsSb + (VOID **) TlsSb ); - if (TlsSb =3D=3D NULL) { + if (*TlsSb =3D=3D NULL) { return NULL; } =20 - Status =3D TlsSb->CreateChild (TlsSb, &TlsChildHandle); + Status =3D (*TlsSb)->CreateChild (*TlsSb, &TlsChildHandle); if (EFI_ERROR (Status)) { return NULL; } =20 Status =3D gBS->OpenProtocol ( @@ -185,11 +185,11 @@ TlsCreateChild ( ImageHandle, TlsChildHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - TlsSb->DestroyChild (TlsSb, TlsChildHandle); + (*TlsSb)->DestroyChild (*TlsSb, TlsChildHandle); return NULL; } =20 Status =3D gBS->OpenProtocol ( TlsChildHandle, @@ -198,11 +198,11 @@ TlsCreateChild ( ImageHandle, TlsChildHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - TlsSb->DestroyChild (TlsSb, TlsChildHandle); + (*TlsSb)->DestroyChild (*TlsSb, TlsChildHandle); return NULL; } =20 return TlsChildHandle; } diff --git a/NetworkPkg/HttpDxe/HttpsSupport.h b/NetworkPkg/HttpDxe/HttpsSu= pport.h index 68a6073..f7a2d30 100644 --- a/NetworkPkg/HttpDxe/HttpsSupport.h +++ b/NetworkPkg/HttpDxe/HttpsSupport.h @@ -1,9 +1,9 @@ /** @file The header files of miscellaneous routines specific to Https for HttpDxe= driver. =20 -Copyright (c) 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 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 @@ -35,20 +35,22 @@ IsHttpsUrl ( =20 /** Creates a Tls child handle, open EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURAT= ION_PROTOCOL. =20 @param[in] ImageHandle The firmware allocated handle for the = UEFI image. + @param[out] TlsSb Pointer to the TLS SERVICE_BINDING_PRO= TOCOL. @param[out] TlsProto Pointer to the EFI_TLS_PROTOCOL instan= ce. @param[out] TlsConfiguration Pointer to the EFI_TLS_CONFIGURATION_P= ROTOCOL instance. =20 @return The child handle with opened EFI_TLS_PROTOCOL and EFI_TLS_CONFI= GURATION_PROTOCOL. =20 **/ EFI_HANDLE EFIAPI TlsCreateChild ( IN EFI_HANDLE ImageHandle, + OUT EFI_SERVICE_BINDING_PROTOCOL **TlsSb, OUT EFI_TLS_PROTOCOL **TlsProto, OUT EFI_TLS_CONFIGURATION_PROTOCOL **TlsConfiguration ); =20 /** --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel