From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 ED1B021BADAB2 for ; Tue, 16 Oct 2018 00:23:55 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 00:23:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,387,1534834800"; d="scan'208";a="97812159" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.9]) by fmsmga004.fm.intel.com with ESMTP; 16 Oct 2018 00:23:54 -0700 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Paulo Alcantara , Ruiyu Ni , Star Zeng Date: Tue, 16 Oct 2018 15:23:39 +0800 Message-Id: <20181016072340.22068-10-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20181016072340.22068-1-hao.a.wu@intel.com> References: <20181016072340.22068-1-hao.a.wu@intel.com> Subject: [PATCH v1 09/10] MdeModulePkg/UdfDxe: Add more check when getting PD from LongAd X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 07:23:56 -0000 REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1254 This commit will add an additional check within function GetPdFromLongAd() when getting a Partition Descriptor from given a Long Allocation Descriptor. According to UDF 2.60 Spec, Section 2.2.13: > The partition reference numbers used are determined by the order of the > Partition Maps in the LVD. (Also the picture comes before the above contents) And a more detailed explanation of the partition reference numbers is at https://sites.google.com/site/udfintro/ (seems not a formal documentation though), Section 5.3.6. Based on the above findings, the 'PartitionReferenceNumber' field in a Long Allocation Descriptor is used as an index to access the Partition Maps data within a Logical Volume Descriptor. Hence, the new check focuses on the validity of this 'PartitionReferenceNumber' field in a Long Allocation Descriptor. Since the current implementation of UdfDxe driver supports only one partition on a Logical Volume, so the value of 'PartitionReferenceNumber' should be 0. Cc: Paulo Alcantara Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index 562a7d983c..7526de79b2 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -241,11 +241,16 @@ GetPdFromLongAd ( // // NOTE: Only one Type 1 (Physical) Partition is supported. It has been // checked already in Partition driver for existence of a single Type 1 - // Partition map, so we don't have to double check here. + // Partition map. Hence, the 'PartitionReferenceNumber' field (the index + // used to access Partition Maps data within the Logical Volume Descriptor) + // in the Long Allocation Descriptor should be 0 to indicate there is only + // one partition. // - // Partition reference number can also be retrieved from - // LongAd->ExtentLocation.PartitionReferenceNumber, however the spec says - // it may be 0, so let's not rely on it. + if (LongAd->ExtentLocation.PartitionReferenceNumber != 0) { + return NULL; + } + // + // Since only one partition, get the first one directly. // PartitionNum = *(UINT16 *)((UINTN)&LogicalVolDesc->PartitionMaps[4]); break; -- 2.12.0.windows.1