From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com []) by mx.groups.io with SMTP id smtpd.web10.2987.1595584489166956048 for ; Fri, 24 Jul 2020 02:54:49 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: guomin.jiang@intel.com) IronPort-SDR: YtASEBRzZ3GlyNWYa+byVhHZy5ttgS/CH3WkGCTkM2BeSMCvINKH7Qzh3/71YZ3MUZza9VT7jB 3EufpbRrKJ1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9691"; a="151973907" X-IronPort-AV: E=Sophos;i="5.75,390,1589266800"; d="scan'208";a="151973907" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2020 02:54:49 -0700 IronPort-SDR: bdGRqtc+eeZBqM/gIiBrz4NEs3VNE//rveAgf417VIeb+4v9opvh4F7qyU6CHxUB4Tlexdna7b NN0dsS1V5WuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,390,1589266800"; d="scan'208";a="319266238" Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by orsmga008.jf.intel.com with ESMTP; 24 Jul 2020 02:54:48 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu Subject: [PATCH v8 1/9] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098) Date: Fri, 24 Jul 2020 17:54:38 +0800 Message-Id: <20200724095446.598-2-guomin.jiang@intel.com> X-Mailer: git-send-email 2.25.1.windows.1 In-Reply-To: <20200724095446.598-1-guomin.jiang@intel.com> References: <20200724095446.598-1-guomin.jiang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614 The security researcher found that we can get control after NEM disable. The reason is that the flash content reside in NEM at startup and the code will get the content from flash directly after disable NEM. To avoid this vulnerability, the feature will copy the PEIMs from temporary memory to permanent memory and only execute the code in permanent memory. The vulnerability is exist in physical platform and haven't report in virtual platform, so the virtual can disable the feature currently. When enable the PcdMigrateTemporaryRamFirmwareVolumes, always shadow all PEIMs no matter the condition of PcdShadowPeimOnBoot or PcdShadowPeimOnS3Boot. Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Guomin Jiang --- MdeModulePkg/MdeModulePkg.dec | 9 +++++++++ MdeModulePkg/MdeModulePkg.uni | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 843e963ad34b..45874e9c8236 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1220,6 +1220,15 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Prompt Shadow Peim and PeiCore on boot gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029 + ## Enable the feature that evacuate temporary memory to permanent memory or not

+ # Set FALSE as default, if the developer need this feature to avoid this vulnerability, please + # enable it to shadow all PEIMs no matter the behavior controled by PcdShadowPeimOnBoot or + # PcdShadowPeimOnS3Boot
+ # TRUE - Evacuate temporary memory, the actions include copy memory, convert PPI pointers and so on.
+ # FALSE - Do nothing, for example, no copy memory, no convert PPI pointers and so on.
+ # @Prompt Evacuate temporary memory to permanent memory + gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE|BOOLEAN|0x3000102A + ## The mask is used to control memory profile behavior.

# BIT0 - Enable UEFI memory profile.
# BIT1 - Enable SMRAM profile.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 2007e0596c4f..5235dee561ad 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -214,6 +214,12 @@ "TRUE - Shadow PEIM on S3 boot path after memory is ready.
\n" "FALSE - Not shadow PEIM on S3 boot path after memory is ready.
" +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_HELP #language en-US "Enable the feature that evacuate temporary memory to permanent memory or not.

\n" + "It will allocate page to save the temporary PEIMs resided in NEM(or CAR) to the permanent memory and change all pointers pointed to the NEM(or CAR) to permanent memory.

\n" + "After then, there are no pointer pointed to NEM(or CAR) and TOCTOU volnerability can be avoid.

\n" + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_PROMPT #language en-US "Enable the feature that evacuate temporary memory to permanent memory or not" + #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_PROMPT #language en-US "Default OEM ID for ACPI table creation" #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_HELP #language en-US "Default OEM ID for ACPI table creation, its length must be 0x6 bytes to follow ACPI specification." -- 2.25.1.windows.1