Blame SOURCES/0026-OvmfPkg-X86QemuLoadImageLib-handle-EFI_ACCESS_DENIED.patch

1d2c45
From bf88198555ce964377a56176de8e5e9b45e43e25 Mon Sep 17 00:00:00 2001
1d2c45
From: Laszlo Ersek <lersek@redhat.com>
1d2c45
Date: Sat, 6 Jun 2020 01:16:09 +0200
1d2c45
Subject: OvmfPkg/X86QemuLoadImageLib: handle EFI_ACCESS_DENIED from
1d2c45
 LoadImage()
1d2c45
MIME-Version: 1.0
1d2c45
Content-Type: text/plain; charset=UTF-8
1d2c45
Content-Transfer-Encoding: 8bit
1d2c45
1d2c45
Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] ->
1d2c45
RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase:
1d2c45
1d2c45
- new patch
1d2c45
1d2c45
- the patch is being upstreamed; it's not a backport because the rebase
1d2c45
  deadline is close
1d2c45
1d2c45
- upstream references:
1d2c45
  - https://bugzilla.tianocore.org/show_bug.cgi?id=2785
1d2c45
  - http://mid.mail-archive.com/20200605235242.32442-1-lersek@redhat.com
1d2c45
  - https://edk2.groups.io/g/devel/message/60825
1d2c45
  - https://www.redhat.com/archives/edk2-devel-archive/2020-June/msg00344.html
1d2c45
1d2c45
[downstream note ends, upstream commit message starts]
1d2c45
1d2c45
When an image fails Secure Boot validation, LoadImage() returns
1d2c45
EFI_SECURITY_VIOLATION if the platform policy is
1d2c45
DEFER_EXECUTE_ON_SECURITY_VIOLATION.
1d2c45
1d2c45
If the platform policy is DENY_EXECUTE_ON_SECURITY_VIOLATION, then
1d2c45
LoadImage() returns EFI_ACCESS_DENIED (and the image does not remain
1d2c45
loaded).
1d2c45
1d2c45
(Before <https://bugzilla.tianocore.org/show_bug.cgi?id=2129>, this
1d2c45
difference would be masked, as DxeImageVerificationLib would incorrectly
1d2c45
return EFI_SECURITY_VIOLATION for DENY_EXECUTE_ON_SECURITY_VIOLATION as
1d2c45
well.)
1d2c45
1d2c45
In X86QemuLoadImageLib, proceed to the legacy Linux/x86 Boot Protocol upon
1d2c45
seeing EFI_ACCESS_DENIED too.
1d2c45
1d2c45
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
1d2c45
Cc: Jordan Justen <jordan.l.justen@intel.com>
1d2c45
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
1d2c45
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2785
1d2c45
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
1d2c45
---
1d2c45
 .../X86QemuLoadImageLib/X86QemuLoadImageLib.c      | 14 ++++++++++----
1d2c45
 1 file changed, 10 insertions(+), 4 deletions(-)
1d2c45
1d2c45
diff --git a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
1d2c45
index ef753be7ea..931553c0c1 100644
1d2c45
--- a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
1d2c45
+++ b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
1d2c45
@@ -320,15 +320,21 @@ QemuLoadKernelImage (
1d2c45
 
1d2c45
   case EFI_SECURITY_VIOLATION:
1d2c45
     //
1d2c45
-    // We are running with UEFI secure boot enabled, and the image failed to
1d2c45
-    // authenticate. For compatibility reasons, we fall back to the legacy
1d2c45
-    // loader in this case. Since the image has been loaded, we need to unload
1d2c45
-    // it before proceeding
1d2c45
+    // Since the image has been loaded, we need to unload it before proceeding
1d2c45
+    // to the EFI_ACCESS_DENIED case below.
1d2c45
     //
1d2c45
     gBS->UnloadImage (KernelImageHandle);
1d2c45
     //
1d2c45
     // Fall through
1d2c45
     //
1d2c45
+  case EFI_ACCESS_DENIED:
1d2c45
+    //
1d2c45
+    // We are running with UEFI secure boot enabled, and the image failed to
1d2c45
+    // authenticate. For compatibility reasons, we fall back to the legacy
1d2c45
+    // loader in this case.
1d2c45
+    //
1d2c45
+    // Fall through
1d2c45
+    //
1d2c45
   case EFI_UNSUPPORTED:
1d2c45
     //
1d2c45
     // The image is not natively supported or cross-type supported. Let's try
1d2c45
-- 
1d2c45
2.18.1
1d2c45