]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/DxeImageVerificationHandler: fix "defer" vs. "deny" policies
authorLaszlo Ersek <lersek@redhat.com>
Thu, 16 Jan 2020 13:45:38 +0000 (14:45 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 31 Jan 2020 09:35:31 +0000 (09:35 +0000)
In DxeImageVerificationHandler(), we should return EFI_SECURITY_VIOLATION
for a rejected image only if the platform sets
DEFER_EXECUTE_ON_SECURITY_VIOLATION as the policy for the image's source.
Otherwise, EFI_ACCESS_DENIED must be returned.

Right now, EFI_SECURITY_VIOLATION is returned for all rejected images,
which is wrong -- it causes LoadImage() to hold on to rejected images (in
untrusted state), for further platform actions. However, if a platform
already set DENY_EXECUTE_ON_SECURITY_VIOLATION, the platform will not
expect the rejected image to stick around in memory (regardless of its
untrusted state).

Therefore, adhere to the platform policy in the return value of the
DxeImageVerificationHandler() function.

Furthermore, according to "32.4.2 Image Execution Information Table" in
the UEFI v2.8 spec, and considering that edk2 only supports (AuditMode==0)
at the moment:

> When AuditMode==0, if the image's signature is not found in the
> authorized database, or is found in the forbidden database, the image
> will not be started and instead, information about it will be placed in
> this table.

we have to store an EFI_IMAGE_EXECUTION_INFO record in both the "defer"
case and the "deny" case. Thus, the AddImageExeInfo() call is not being
made conditional on (Policy == DEFER_EXECUTE_ON_SECURITY_VIOLATION); the
documentation is updated instead.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2129
Fixes: 5db28a6753d307cdfb1cfdeb2f63739a9f959837
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200116190705.18816-12-lersek@redhat.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
[lersek@redhat.com: push with Mike's R-b due to Chinese New Year
 Holiday: <https://edk2.groups.io/g/devel/message/53429>; msgid
 <d3fbb76dabed4e1987c512c328c82810@intel.com>]

SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c

index 015a5b61a3012860f0a9452b074e02659f0cb451..dbfbfcb4fb3aa5a26ecd37d2227e160e946c2f2b 100644 (file)
@@ -1548,7 +1548,8 @@ Done:
                                  execution table.\r
   @retval EFI_ACCESS_DENIED      The file specified by File and FileBuffer did not\r
                                  authenticate, and the platform policy dictates that the DXE\r
-                                 Foundation many not use File.\r
+                                 Foundation may not use File. The image has\r
+                                 been added to the file execution table.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1872,7 +1873,8 @@ DxeImageVerificationHandler (
 \r
 Failed:\r
   //\r
-  // Policy decides to defer or reject the image; add its information in image executable information table.\r
+  // Policy decides to defer or reject the image; add its information in image\r
+  // executable information table in either case.\r
   //\r
   NameStr = ConvertDevicePathToText (File, FALSE, TRUE);\r
   AddImageExeInfo (Action, NameStr, File, SignatureList, SignatureListSize);\r
@@ -1885,7 +1887,10 @@ Failed:
     FreePool (SignatureList);\r
   }\r
 \r
-  return EFI_SECURITY_VIOLATION;\r
+  if (Policy == DEFER_EXECUTE_ON_SECURITY_VIOLATION) {\r
+    return EFI_SECURITY_VIOLATION;\r
+  }\r
+  return EFI_ACCESS_DENIED;\r
 }\r
 \r
 /**\r