From nobody Mon Feb 9 21:21:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+91385+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91385+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1657836290; cv=none; d=zohomail.com; s=zohoarc; b=ZMjf/mpOtLis6Sff0r8Cy2sARXAggnMUV2pzL8Ep31DyFczLp7IV23unrLAqd+To3vxnFRJQ0UjhgQeeVPqKYMFjS2rCE/oQHGVAz/Af8DZRLlINbkZQzs3K02RIB3su/rCrQLVaINhnIYDflxWxRteGQ9ikY6cnbVLLIHgGkJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657836290; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=pyPJy/BJ4gowDZTIrwzlOHgEZW5HkuHPOnCgn8SsQLg=; b=W3912+hDHCKoiwIdKau5L0mPCPg6UmrCEDRp9TbVb7iW4tQi3OPfMVhMhWrC6nPpbMwsZ4O0jXXZSJGz/Ly8jQAzGxEkFkDPkc/VCxhleJSdQaRPyshJaaJdU3u/wx5+YBPrT7DwZeshR85T6ZM+zMFiMwiPG+g4/eRf94ZavKo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91385+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 165783629016235.31952974272599; Thu, 14 Jul 2022 15:04:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id pAkDYY1788612xyir7Ftpxjr; Thu, 14 Jul 2022 15:04:49 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.2325.1657836288174243203 for ; Thu, 14 Jul 2022 15:04:48 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10408"; a="285661706" X-IronPort-AV: E=Sophos;i="5.92,272,1650956400"; d="scan'208";a="285661706" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 15:04:43 -0700 X-IronPort-AV: E=Sophos;i="5.92,272,1650956400"; d="scan'208";a="623600221" X-Received: from jvang-mobl.amr.corp.intel.com ([10.209.53.127]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 15:04:42 -0700 From: "Judah Vang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Xiaoyu Lu , Guomin Jiang , Nishant C Mistry Subject: [edk2-devel] [PATCH v3 1/3] CryptoPkg: Fix memoryleak in BaseMemAllocation Date: Thu, 14 Jul 2022 15:04:14 -0700 Message-Id: <20220714220416.1660-2-judah.vang@intel.com> In-Reply-To: <20220714220416.1660-1-judah.vang@intel.com> References: <20220714220416.1660-1-judah.vang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,judah.vang@intel.com X-Gm-Message-State: ru8WLwnCw2aHLcptmkVxPDxrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1657836289; bh=2iO7S/OItZWW6VKCaNJaWpXWkRNZkkhA28V+t3HnmcE=; h=Cc:Date:From:Reply-To:Subject:To; b=B4bnQTcLWSa0duILa/J+hwQmDbuDr+695tsSgX0xyr3gT0JT4+j53qHWzvYDkTpGeT9 S3YPh8OZCNf6WtV8+3Am7y3J3sAAaaM0VcYqu++XP03kZz5v86zJluKRgp5X1SohMzgsD JTWWSzoxWy54eNQN8o5O1a/3P3kU8uP5Uds= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1657836291576100004 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3990 Replace AllocatePool() with AllocatePages() and FreePool() with FreePages() because FreePool() is not supported in PEI phase. FreePool() does not free the allocated pool in PEI phase causing a memory leak. Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang Cc: Nishant C Mistry Signed-off-by: Jian J Wang Signed-off-by: Nishant C Mistry Signed-off-by: Judah Vang --- CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c b/C= ryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c index b7bed15c18df..d77e1f7de5e3 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c @@ -2,13 +2,14 @@ Base Memory Allocation Routines Wrapper for Crypto library over OpenSSL during PEI & DXE phases. =20 -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include #include +#include =20 // // Extra header to record the memory buffer size from malloc routine. @@ -41,7 +42,7 @@ malloc ( // NewSize =3D (UINTN)(size) + CRYPTMEM_OVERHEAD; =20 - Data =3D AllocatePool (NewSize); + Data =3D AllocatePages (EFI_SIZE_TO_PAGES (NewSize)); if (Data !=3D NULL) { PoolHdr =3D (CRYPTMEM_HEAD *)Data; // @@ -73,7 +74,7 @@ realloc ( VOID *Data; =20 NewSize =3D (UINTN)size + CRYPTMEM_OVERHEAD; - Data =3D AllocatePool (NewSize); + Data =3D AllocatePages (EFI_SIZE_TO_PAGES (NewSize)); if (Data !=3D NULL) { NewPoolHdr =3D (CRYPTMEM_HEAD *)Data; NewPoolHdr->Signature =3D CRYPTMEM_HEAD_SIGNATURE; @@ -90,7 +91,7 @@ realloc ( // Duplicate the buffer content. // CopyMem ((VOID *)(NewPoolHdr + 1), ptr, MIN (OldSize, size)); - FreePool ((VOID *)OldPoolHdr); + FreePages (((VOID *)OldPoolHdr), EFI_SIZE_TO_PAGES (OldSize)); } =20 return (VOID *)(NewPoolHdr + 1); @@ -117,6 +118,6 @@ free ( if (ptr !=3D NULL) { PoolHdr =3D (CRYPTMEM_HEAD *)ptr - 1; ASSERT (PoolHdr->Signature =3D=3D CRYPTMEM_HEAD_SIGNATURE); - FreePool (PoolHdr); + FreePages (((VOID *)PoolHdr), EFI_SIZE_TO_PAGES (PoolHdr->Size)); } } --=20 2.35.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91385): https://edk2.groups.io/g/devel/message/91385 Mute This Topic: https://groups.io/mt/92389738/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-