From nobody Sun May 5 23:25:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+39353+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+39353+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1555898174; cv=none; d=zoho.com; s=zohoarc; b=YBEO3ikLXu4hqOzawddkSRxdQucWR4Z86bDuHuMou3Xjm6Dx0DZ54jYXJpnY8rGg7fknhMoVrOSYTolhE8a7wtqdPARaAF454x+ihhcWXmxgxhtzCGNS/5trEN3Pa8F23C62a9eMSphOCj0w2RDPa7uz342sh8XYFUPo+qFCIhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555898174; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=JMzUJa+Qpgjq49b0bH855A7X7T+dLO/wQw4kqJk99C4=; b=JUWnhUr/mUO8TkEeIg9FqzbwGMk59Mn72+3S3TCjR/D+rShCWgI6b6uwAvOuyrWBm3v22qfIVnXLBwlTqdJq0eoFjZz1G+eoB8ihiMV9WUSnXNG+98hJbVN8z8DKi2HxULefDGmItC45A4hyGrIW4IPwN54IGpFQIatHhVSgnmY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+39353+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1555898174148674.2186794680413; Sun, 21 Apr 2019 18:56:14 -0700 (PDT) Return-Path: X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Sun, 21 Apr 2019 18:56:13 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Apr 2019 18:56:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,380,1549958400"; d="scan'208";a="225499595" X-Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.147]) by orsmga001.jf.intel.com with ESMTP; 21 Apr 2019 18:56:11 -0700 From: "Dandan Bi" To: devel@edk2.groups.io Cc: Hao Wu , Ray Ni , Liming Gao Subject: [edk2-devel] [patch] MdeModulePkg/HiiDatabaseDxe: Release lock on all error return path Date: Mon, 22 Apr 2019 09:56:07 +0800 Message-Id: <20190422015607.14620-1-dandan.bi@intel.com> Precedence: Bulk List-Unsubscribe: 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,dandan.bi@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1555898173; bh=+fAmaFNjr+nmMG3BF7VbLkVUnWBQy28v758VwSfoTbw=; h=Cc:Date:From:Reply-To:Subject:To; b=Dy8de+A1ZhLOFO4PUysQEec2R1GxGETsdJn4cmaicUlOTUfHS7Ug1uEUEcRF5d5rBZO AIMJ84aYGnTV1GsVHWR2FT0zxXEnkrd49fRO3pP6AI9+zqNHw5RQr8zO0IFjlMDXo1X1u RIEezb07LJgfDBzzI3yKIzViv7e9sWphlkQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1652 Commit ffe5f7a6b4e9 "MdeModulePkg/HiiDatabase: Fix potential integer overflow " added some new error paths, but it missed releasing the mHiiDatabaseLock lock on those paths. This patch releases mHiiDatabaseLock on those paths. Cc: Hao Wu Cc: Ray Ni Cc: Liming Gao Signed-off-by: Dandan Bi Reviewed-by: Hao Wu --- MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/U= niversal/HiiDatabaseDxe/Image.c index bd623cae15..a108fc6157 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c @@ -1,10 +1,10 @@ /** @file Implementation for EFI_HII_IMAGE_PROTOCOL. =20 =20 -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 =20 @@ -651,10 +651,11 @@ HiiNewImage ( // Make sure the size doesn't overflow UINT32. // Note: 24Bit BMP occpuies 3 bytes per pixel. // NewBlockSize =3D (UINT32)Image->Width * Image->Height; if (NewBlockSize > (MAX_UINT32 - (sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK= ) - sizeof (EFI_HII_RGB_PIXEL))) / 3) { + EfiReleaseLock (&mHiiDatabaseLock); return EFI_OUT_OF_RESOURCES; } NewBlockSize =3D NewBlockSize * 3 + (sizeof (EFI_HII_IIBT_IMAGE_24BIT_BL= OCK) - sizeof (EFI_HII_RGB_PIXEL)); =20 // @@ -678,10 +679,11 @@ HiiNewImage ( // // Make sure the final package length doesn't overflow. // Length of the package header is represented using 24 bits. So MAX l= ength is MAX_UINT24. // if (NewBlockSize > MAX_UINT24 - ImagePackage->ImagePkgHdr.Header.Lengt= h) { + EfiReleaseLock (&mHiiDatabaseLock); return EFI_OUT_OF_RESOURCES; } // // Because ImagePackage->ImageBlockSize < ImagePackage->ImagePkgHdr.He= ader.Length, // So (ImagePackage->ImageBlockSize + NewBlockSize) <=3D MAX_UINT24 @@ -719,10 +721,11 @@ HiiNewImage ( // // Make sure the final package length doesn't overflow. // Length of the package header is represented using 24 bits. So MAX l= ength is MAX_UINT24. // if (NewBlockSize > MAX_UINT24 - (sizeof (EFI_HII_IMAGE_PACKAGE_HDR) + = sizeof (EFI_HII_IIBT_END_BLOCK))) { + EfiReleaseLock (&mHiiDatabaseLock); return EFI_OUT_OF_RESOURCES; } // // The specified package list does not contain image package. // Create one to add this image block. @@ -1159,16 +1162,18 @@ HiiSetImage ( // Length of the package header is represented using 24 bits. So MAX len= gth is MAX_UINT24. // 24Bit BMP occpuies 3 bytes per pixel. // NewBlockSize =3D (UINT32)Image->Width * Image->Height; if (NewBlockSize > (MAX_UINT32 - (sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK= ) - sizeof (EFI_HII_RGB_PIXEL))) / 3) { + EfiReleaseLock (&mHiiDatabaseLock); return EFI_OUT_OF_RESOURCES; } NewBlockSize =3D NewBlockSize * 3 + (sizeof (EFI_HII_IIBT_IMAGE_24BIT_BL= OCK) - sizeof (EFI_HII_RGB_PIXEL)); if ((NewBlockSize > OldBlockSize) && (NewBlockSize - OldBlockSize > MAX_UINT24 - ImagePackage->ImagePkgHd= r.Header.Length) ) { + EfiReleaseLock (&mHiiDatabaseLock); return EFI_OUT_OF_RESOURCES; } =20 // // Adjust the image package to remove the original block firstly then ad= d the new block. --=20 2.18.0.windows.1 -=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 (#39353): https://edk2.groups.io/g/devel/message/39353 Mute This Topic: https://groups.io/mt/31269775/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-