]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SdMmcPciHcDxe: Fix double PciIo Unmap in TRB creation (CVE-2019-14587)
authorHao A Wu <hao.a.wu@intel.com>
Wed, 26 Jun 2019 07:23:29 +0000 (15:23 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 18 Feb 2020 05:03:49 +0000 (05:03 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1989

The commit will avoid unmapping the same resource in error handling logic
for function BuildAdmaDescTable() and SdMmcCreateTrb().

For the error handling in BuildAdmaDescTable():
The error is directly related with the corresponding Map() operation
(mapped address beyond 4G, which is not supported in ADMA), so the Unmap()
operation is done in the error handling logic, and then setting
'Trb->AdmaMap' to NULL to avoid double Unmap.

For the error handling in SdMmcCreateTrb():
The error is not directly related with the corresponding Map() operation,
so the commit will update the code to left SdMmcFreeTrb() for the Unmap
operation to avoid double Unmap.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c

index da5559ae76e3db3bf8adf8575d6c8964feea990b..43626fff48f21a3974f16a2eb0355746e256e083 100644 (file)
@@ -1544,6 +1544,8 @@ BuildAdmaDescTable (
       PciIo,\r
       Trb->AdmaMap\r
     );\r
+    Trb->AdmaMap = NULL;\r
+\r
     PciIo->FreeBuffer (\r
       PciIo,\r
       EFI_SIZE_TO_PAGES (TableSize),\r
@@ -1753,7 +1755,6 @@ SdMmcCreateTrb (
       }\r
       Status = BuildAdmaDescTable (Trb, Private->ControllerVersion[Slot]);\r
       if (EFI_ERROR (Status)) {\r
-        PciIo->Unmap (PciIo, Trb->DataMap);\r
         goto Error;\r
       }\r
     } else if (Private->Capability[Slot].Sdma != 0) {\r