From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: devel@edk2.groups.io
Cc: jian.j.wang@intel.com, hao.a.wu@intel.com, ray.ni@intel.com,
glin@suse.com, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v2] MdeModulePkg/UefiBootManagerLib: fix crash on uninitialized ExitData
Date: Tue, 16 Apr 2019 23:40:47 -0700 [thread overview]
Message-ID: <20190417064047.4676-1-ard.biesheuvel@linaro.org> (raw)
As reported by Gary, the recent LoadImage/StartImage changes to
accommodate dispatching PE/COFF images built for foreign architectures
may result in a crash when loading an IA32 option ROM into a X64 VM
running OVMF:
Loading driver at 0x0007E537000 EntryPoint=0x0007E53C06D 8086100e.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7F003B98
ProtectUefiImageCommon - 0x7F002BC0
- 0x000000007E537000 - 0x000000000009F900
Image type IA32 can't be started on X64 UEFI system.
ASSERT MdeModulePkg/Core/Dxe/Mem/Pool.c(698): Head->Signature == ((('p') |
('h' << 8)) | ((('d') | ('0' << 8)) << 16)) || Head->Signature
== ((('p') | ('h' << 8)) | ((('d') | ('1' << 8)) << 16))
This turns out to be caused by the deferred image loading code in BDS,
which doesn't check the result code of gBS->StartImage(), and ends up
trying to free an uninitialized pointer.
Given that ExitData is never actually used, let's just get rid of it
entirely. While we're at it, drop the pointless assignment of Status
as well.
Tested-by: Gary Lin <glin@suse.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
v2: drop ExitData entirely instead of initializing it to NULL
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index fc8775dfa419..6b8fb4d92461 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -439,8 +439,6 @@ EfiBootManagerDispatchDeferredImages (
UINTN ImageSize;
BOOLEAN BootOption;
EFI_HANDLE ImageHandle;
- UINTN ExitDataSize;
- CHAR16 *ExitData;
UINTN ImageCount;
UINTN LoadCount;
@@ -502,10 +500,7 @@ EfiBootManagerDispatchDeferredImages (
// a 5 Minute period
//
gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
- Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
- if (ExitData != NULL) {
- FreePool (ExitData);
- }
+ gBS->StartImage (ImageHandle, NULL, NULL);
//
// Clear the Watchdog Timer after the image returns.
--
2.17.1
next reply other threads:[~2019-04-17 6:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 6:40 Ard Biesheuvel [this message]
2019-04-17 13:09 ` [edk2-devel] [PATCH v2] MdeModulePkg/UefiBootManagerLib: fix crash on uninitialized ExitData Laszlo Ersek
2019-04-17 16:45 ` Ard Biesheuvel
2019-04-18 1:00 ` Wu, Hao A
2019-04-18 1:04 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190417064047.4676-1-ard.biesheuvel@linaro.org \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox