From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1639.1581566610064274437 for ; Wed, 12 Feb 2020 20:03:30 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: dandan.bi@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2020 20:03:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,434,1574150400"; d="scan'208";a="380976067" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.126]) by orsmga004.jf.intel.com with ESMTP; 12 Feb 2020 20:03:28 -0800 From: "Dandan Bi" To: devel@edk2.groups.io Cc: Liming Gao , Eric Dong , Jian J Wang Subject: [patch] MdeModulePkg/HiiDB: Remove configuration table when it's freed (CVE-2019-14586) Date: Thu, 13 Feb 2020 12:03:01 +0800 Message-Id: <20200213040303.53336-1-dandan.bi@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1995 Fix the corner case issue that the original configuration runtime memory is freed, but it is still exposed to the OS runtime. So this patch is to remove the configuration table to avoid being used in OS runtime when the configuration runtime memory is freed. Cc: Liming Gao Cc: Eric Dong Cc: Jian J Wang Signed-off-by: Dandan Bi Reviewed-by: Eric Dong --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index d3791ca68b..36265b8ff9 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -3374,10 +3374,14 @@ HiiGetConfigRespInfo( } gRTConfigRespBuffer = (EFI_STRING) AllocateRuntimeZeroPool (gConfigRespSize); if (gRTConfigRespBuffer == NULL){ FreePool(ConfigAltResp); DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough memory resource to store the ConfigResp string.\n")); + // + // Remove from the System Table when the configuration runtime buffer is freed. + // + gBS->InstallConfigurationTable (&gEfiHiiConfigRoutingProtocolGuid, NULL); return EFI_OUT_OF_RESOURCES; } } else { ZeroMem(gRTConfigRespBuffer,gConfigRespSize); } @@ -3429,10 +3433,14 @@ HiiGetDatabaseInfo( DEBUG ((DEBUG_WARN, "[HiiDatabase]: Memory allocation is required after ReadyToBoot, which may change memory map and cause S4 resume issue.\n")); } gRTDatabaseInfoBuffer = AllocateRuntimeZeroPool (gDatabaseInfoSize); if (gRTDatabaseInfoBuffer == NULL){ DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough memory resource to store the HiiDatabase info.\n")); + // + // Remove from the System Table when the configuration runtime buffer is freed. + // + gBS->InstallConfigurationTable (&gEfiHiiDatabaseProtocolGuid, NULL); return EFI_OUT_OF_RESOURCES; } } else { ZeroMem(gRTDatabaseInfoBuffer,gDatabaseInfoSize); } -- 2.18.0.windows.1