From nobody Wed Dec 25 01:48:43 2024 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 1510818471998514.5301894191654; Wed, 15 Nov 2017 23:47:51 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5D55820356863; Wed, 15 Nov 2017 23:43:41 -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 EF8FC21B00DD6 for ; Wed, 15 Nov 2017 23:43:39 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2017 23:47:49 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by FMSMGA003.fm.intel.com with ESMTP; 15 Nov 2017 23:47:48 -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=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,402,1505804400"; d="scan'208";a="2419310" From: Hao Wu To: edk2-devel@lists.01.org Date: Thu, 16 Nov 2017 15:47:41 +0800 Message-Id: <20171116074742.15024-2-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20171116074742.15024-1-hao.a.wu@intel.com> References: <20171116074742.15024-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/PartitionDxe: Merge the discovery of ElTorito into UDF 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: Hao Wu , Ruiyu Ni , Eric Dong , Star Zeng 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" In order to create all of the children (El Torito standard and UDF) for a CD/DVD media in an entry of the PartitionDriverBindingStart(), this commit merges the discovery of the El Torito feature (PartitionInstallElToritoChildHandles) into function PartitionInstallUdfChildHandles. Cc: Paulo Alcantara Cc: Ruiyu Ni Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Paulo Alcantara --- MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 7 +++-- MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c | 27 ++++++++++++++++= ++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModu= lePkg/Universal/Disk/PartitionDxe/Partition.c index f6030e0897..603abfe55a 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c @@ -43,7 +43,6 @@ EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding =3D { // PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] =3D { PartitionInstallGptChildHandles, - PartitionInstallElToritoChildHandles, PartitionInstallMbrChildHandles, PartitionInstallUdfChildHandles, NULL @@ -306,9 +305,9 @@ PartitionDriverBindingStart ( if (BlockIo->Media->MediaPresent || (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition= )) { // - // Try for GPT, then El Torito, then UDF, and then legacy MBR partition - // types. If the media supports a given partition type install child h= andles - // to represent the partitions described by the media. + // Try for GPT, then legacy MBR partition types, and then UDF and El T= orito. + // If the media supports a given partition type install child handles = to + // represent the partitions described by the media. // Routine =3D &mPartitionDetectRoutineTable[0]; while (*Routine !=3D NULL) { diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c b/MdeModulePkg/= Universal/Disk/PartitionDxe/Udf.c index 7eee748958..5aac5640f6 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c @@ -688,8 +688,10 @@ PartitionInstallUdfChildHandles ( EFI_PARTITION_INFO_PROTOCOL PartitionInfo; EFI_LBA StartingLBA; EFI_LBA EndingLBA; + BOOLEAN ChildCreated; =20 Media =3D BlockIo->Media; + ChildCreated =3D FALSE; =20 // // Check if UDF logical block size is multiple of underlying device bloc= k size @@ -704,11 +706,29 @@ PartitionInstallUdfChildHandles ( } =20 // + // Detect El Torito feature first. + // And always continue to search for UDF. + // + Status =3D PartitionInstallElToritoChildHandles ( + This, + Handle, + DiskIo, + DiskIo2, + BlockIo, + BlockIo2, + DevicePath + ); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "PartitionDxe: El Torito standard found on handle = 0x%p.\n", Handle)); + ChildCreated =3D TRUE; + } + + // // Search for an UDF file system on block device // Status =3D FindUdfFileSystem (BlockIo, DiskIo, &StartingLBA, &EndingLBA); if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; + return (ChildCreated ? EFI_SUCCESS : EFI_NOT_FOUND); } =20 // @@ -735,6 +755,9 @@ PartitionInstallUdfChildHandles ( EndingLBA, Media->BlockSize ); + if (EFI_ERROR (Status)) { + return (ChildCreated ? EFI_SUCCESS : Status); + } =20 - return Status; + return EFI_SUCCESS; } --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed Dec 25 01:48:43 2024 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 1510818481204231.47859022355533; Wed, 15 Nov 2017 23:48:01 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9B8E520355611; Wed, 15 Nov 2017 23:43:50 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 7B26C220D4BFE for ; Wed, 15 Nov 2017 23:43:49 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2017 23:47:58 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by FMSMGA003.fm.intel.com with ESMTP; 15 Nov 2017 23:47:57 -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=134.134.136.24; helo=mga09.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,402,1505804400"; d="scan'208";a="2419353" From: Hao Wu To: edk2-devel@lists.01.org Date: Thu, 16 Nov 2017 15:47:42 +0800 Message-Id: <20171116074742.15024-3-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20171116074742.15024-1-hao.a.wu@intel.com> References: <20171116074742.15024-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH v2 2/2] MdeModulePkg/UdfDxe: Avoid possible loss track of allocated buffer 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: Hao Wu , Ruiyu Ni , Eric Dong , Star Zeng 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" In function FindFileEntry(): Instead of using the function parameter 'FileEntry', use a local variable to store the buffer allocated for disk read operation. For the below calling stack: UdfOpenVolume() -> FindRootDirectory() -> FindFileEntry() In FindFileEntry(), the call to 'DiskIo->ReadDisk()' is possible (e.g. media change for a CD/DVD ROM device) to trigger a re-install of the BlockIO(2) protocol which will further lead to a call of the BindingStop() & BingdingStart() of the UdfDxe driver. Meanwhile, for the above listed calling stack, the '**FileEntry' parameter passed into FindFileEntry() is '&PrivFsData->Root'. 'PrivFsData' is a driver-managed private data, it will be freed in BindingStop() and re-allocate in BingdingStart(). In such case, if '*FileEntry' is used to store the allocated buffer, the information will be lost if 'DiskIo->ReadDisk()' triggers a re-install of the BlockIO(2) protocol. The subsequent call of the FreePool API: FreePool (*FileEntry); will cause issues. This commit uses a local variable to store the allocated buffer. Cc: Ruiyu Ni Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Paulo Alcantara --- MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/Md= eModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index e048d95d31..ecc172303e 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -1615,12 +1615,13 @@ FindFileEntry ( UINT64 Lsn; UINT32 LogicalBlockSize; UDF_DESCRIPTOR_TAG *DescriptorTag; + VOID *ReadBuffer; =20 Lsn =3D GetLongAdLsn (Volume, Icb); LogicalBlockSize =3D Volume->LogicalVolDesc.LogicalBlockSize; =20 - *FileEntry =3D AllocateZeroPool (Volume->FileEntrySize); - if (*FileEntry =3D=3D NULL) { + ReadBuffer =3D AllocateZeroPool (Volume->FileEntrySize); + if (ReadBuffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 @@ -1632,13 +1633,13 @@ FindFileEntry ( BlockIo->Media->MediaId, MultU64x32 (Lsn, LogicalBlockSize), Volume->FileEntrySize, - *FileEntry + ReadBuffer ); if (EFI_ERROR (Status)) { goto Error_Read_Disk_Blk; } =20 - DescriptorTag =3D *FileEntry; + DescriptorTag =3D ReadBuffer; =20 // // Check if the read extent contains a valid Tag Identifier for the expe= cted @@ -1650,11 +1651,12 @@ FindFileEntry ( goto Error_Invalid_Fe; } =20 + *FileEntry =3D ReadBuffer; return EFI_SUCCESS; =20 Error_Invalid_Fe: Error_Read_Disk_Blk: - FreePool (*FileEntry); + FreePool (ReadBuffer); =20 return Status; } --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel