Blame SOURCES/edk2-SecurityPkg-DxeImageVerificationHandler-fix-retval-o.patch

6009e6
From 58902877128851f628fe644a5c71600866317fac Mon Sep 17 00:00:00 2001
6009e6
From: Laszlo Ersek <lersek@redhat.com>
6009e6
Date: Fri, 31 Jan 2020 12:42:42 +0100
6009e6
Subject: [PATCH 06/12] SecurityPkg/DxeImageVerificationHandler: fix retval on
6009e6
 memalloc failure
6009e6
MIME-Version: 1.0
6009e6
Content-Type: text/plain; charset=UTF-8
6009e6
Content-Transfer-Encoding: 8bit
6009e6
6009e6
RH-Author: Laszlo Ersek <lersek@redhat.com>
6009e6
Message-id: <20200131124248.22369-7-lersek@redhat.com>
6009e6
Patchwork-id: 93616
6009e6
O-Subject: [RHEL-8.2.0 edk2 PATCH 06/12] SecurityPkg/DxeImageVerificationHandler: fix retval on memalloc failure
6009e6
Bugzilla: 1751993
6009e6
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6009e6
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6009e6
6009e6
A SECURITY2_FILE_AUTHENTICATION_HANDLER function is not expected to return
6009e6
EFI_OUT_OF_RESOURCES. We should only return EFI_SUCCESS,
6009e6
EFI_SECURITY_VIOLATION, or EFI_ACCESS_DENIED.
6009e6
6009e6
In case we run out of memory while preparing "SignatureList" for
6009e6
AddImageExeInfo(), we should simply stick with the EFI_ACCESS_DENIED value
6009e6
that is already in "Status" -- from just before the "Action" condition --,
6009e6
and not suppress it with EFI_OUT_OF_RESOURCES.
6009e6
6009e6
This patch does not change the control flow in the function, it only
6009e6
changes the "Status" outcome from API-incompatible error codes to
6009e6
EFI_ACCESS_DENIED, under some circumstances.
6009e6
6009e6
Cc: Chao Zhang <chao.b.zhang@intel.com>
6009e6
Cc: Jian J Wang <jian.j.wang@intel.com>
6009e6
Cc: Jiewen Yao <jiewen.yao@intel.com>
6009e6
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2129
6009e6
Fixes: 570b3d1a7278df29878da87990e8366bd42d0ec5
6009e6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6009e6
Message-Id: <20200116190705.18816-6-lersek@redhat.com>
6009e6
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
6009e6
[lersek@redhat.com: push with Mike's R-b due to Chinese New Year
6009e6
 Holiday: <https://edk2.groups.io/g/devel/message/53429>; msgid
6009e6
 <d3fbb76dabed4e1987c512c328c82810@intel.com>]
6009e6
(cherry picked from commit f891b052c5ec13c1032fb9d340d5262ac1a7e7e1)
6009e6
6009e6
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
6009e6
---
6009e6
 SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c | 2 --
6009e6
 1 file changed, 2 deletions(-)
6009e6
6009e6
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
6009e6
index 5cc82c1..5f09a66 100644
6009e6
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
6009e6
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
6009e6
@@ -1541,7 +1541,6 @@ Done:
6009e6
                                  and non-NULL FileBuffer did authenticate, and the platform
6009e6
                                  policy dictates that the DXE Foundation may execute the image in
6009e6
                                  FileBuffer.
6009e6
-  @retval EFI_OUT_RESOURCE       Fail to allocate memory.
6009e6
   @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and
6009e6
                                  the platform policy dictates that File should be placed
6009e6
                                  in the untrusted state. The image has been added to the file
6009e6
@@ -1862,7 +1861,6 @@ DxeImageVerificationHandler (
6009e6
     SignatureListSize = sizeof (EFI_SIGNATURE_LIST) + sizeof (EFI_SIGNATURE_DATA) - 1 + mImageDigestSize;
6009e6
     SignatureList     = (EFI_SIGNATURE_LIST *) AllocateZeroPool (SignatureListSize);
6009e6
     if (SignatureList == NULL) {
6009e6
-      Status = EFI_OUT_OF_RESOURCES;
6009e6
       goto Done;
6009e6
     }
6009e6
     SignatureList->SignatureHeaderSize  = 0;
6009e6
-- 
6009e6
1.8.3.1
6009e6