88 lines
4.0 KiB
Diff
88 lines
4.0 KiB
Diff
From d9f12d175da2d203be078d03c9127293ea6fe86b Mon Sep 17 00:00:00 2001
|
|
From: Laszlo Ersek <lersek@redhat.com>
|
|
Date: Fri, 31 Jan 2020 12:42:47 +0100
|
|
Subject: [PATCH 11/12] SecurityPkg/DxeImageVerificationHandler: fix imgexec
|
|
info on memalloc fail
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
Message-id: <20200131124248.22369-12-lersek@redhat.com>
|
|
Patchwork-id: 93618
|
|
O-Subject: [RHEL-8.2.0 edk2 PATCH 11/12] SecurityPkg/DxeImageVerificationHandler: fix imgexec info on memalloc fail
|
|
Bugzilla: 1751993
|
|
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
|
It makes no sense to call AddImageExeInfo() with (Signature == NULL) and
|
|
(SignatureSize > 0). AddImageExeInfo() does not crash in such a case -- it
|
|
avoids the CopyMem() call --, but it creates an invalid
|
|
EFI_IMAGE_EXECUTION_INFO record. Namely, the
|
|
"EFI_IMAGE_EXECUTION_INFO.InfoSize" field includes "SignatureSize", but
|
|
the actual signature bytes are not filled in.
|
|
|
|
Document and ASSERT() this condition in AddImageExeInfo().
|
|
|
|
In DxeImageVerificationHandler(), zero out "SignatureListSize" if we set
|
|
"SignatureList" to NULL due to AllocateZeroPool() failure.
|
|
|
|
(Another approach could be to avoid calling AddImageExeInfo() completely,
|
|
in case AllocateZeroPool() fails. Unfortunately, the UEFI v2.8 spec does
|
|
not seem to state clearly whether a signature is mandatory in
|
|
EFI_IMAGE_EXECUTION_INFO, if the "Action" field is
|
|
EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED or EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND.
|
|
|
|
For now, the EFI_IMAGE_EXECUTION_INFO addition logic is not changed; we
|
|
only make sure that the record we add is not malformed.)
|
|
|
|
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
|
|
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
Message-Id: <20200116190705.18816-11-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>]
|
|
(cherry picked from commit 6aa31db5ebebe18b55aa5359142223a03592416f)
|
|
|
|
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
---
|
|
SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c | 4 +++-
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
|
|
index c98b9e4..015a5b6 100644
|
|
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
|
|
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
|
|
@@ -704,7 +704,7 @@ GetImageExeInfoTableSize (
|
|
@param[in] Name Input a null-terminated, user-friendly name.
|
|
@param[in] DevicePath Input device path pointer.
|
|
@param[in] Signature Input signature info in EFI_SIGNATURE_LIST data structure.
|
|
- @param[in] SignatureSize Size of signature.
|
|
+ @param[in] SignatureSize Size of signature. Must be zero if Signature is NULL.
|
|
|
|
**/
|
|
VOID
|
|
@@ -761,6 +761,7 @@ AddImageExeInfo (
|
|
//
|
|
// Signature size can be odd. Pad after signature to ensure next EXECUTION_INFO entry align
|
|
//
|
|
+ ASSERT (Signature != NULL || SignatureSize == 0);
|
|
NewImageExeInfoEntrySize = sizeof (EFI_IMAGE_EXECUTION_INFO) + NameStringLen + DevicePathSize + SignatureSize;
|
|
|
|
NewImageExeInfoTable = (EFI_IMAGE_EXECUTION_INFO_TABLE *) AllocateRuntimePool (ImageExeInfoTableSize + NewImageExeInfoEntrySize);
|
|
@@ -1858,6 +1859,7 @@ DxeImageVerificationHandler (
|
|
SignatureListSize = sizeof (EFI_SIGNATURE_LIST) + sizeof (EFI_SIGNATURE_DATA) - 1 + mImageDigestSize;
|
|
SignatureList = (EFI_SIGNATURE_LIST *) AllocateZeroPool (SignatureListSize);
|
|
if (SignatureList == NULL) {
|
|
+ SignatureListSize = 0;
|
|
goto Failed;
|
|
}
|
|
SignatureList->SignatureHeaderSize = 0;
|
|
--
|
|
1.8.3.1
|
|
|