
On Thu, Aug 09, 2018 at 07:55:06AM +0100, Alexander Graf wrote:
On 09.08.18 07:15, AKASHI Takahiro wrote:
The commit 21b3edfc964 ("efi_loader: check parameters of CreateEvent") enforces a strict parameter check at CreateEvent(). Unfortunately, however, EDK2's Shell.efi calls this function with notify_tpl == 0.
The patch above does right thing and we'd better fix the issue on EDK2 side, and yet we might want a workaround allowing for running un-modified version of EDK2 in short-term solution.
... of the EDK2 shell ...
and it's not just about short term - we always want to be compatible :).
Okay.
So what's the reason this does not trigger in edk2? Are they considering TPL 0 a valid TPL always or did they just forget the check in create event? If they always consider TPL 0 valid, we better change is_valid_tpl to ensure compatibility with edk2's behavior.
I'm not confident about what Shell's intent is. Created here is an event to be used to raise a signal for "notification of Ctrl-C keystrokes," and hence Shell expects such key data to always be sent to a task whatever its TPL is?
The patch provides a minimum mitigation of parameter check.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
lib/efi_loader/efi_boottime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 2281703f261..e7a19c35415 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -627,7 +627,8 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, return EFI_INVALID_PARAMETER; }
- if (is_valid_tpl(notify_tpl) != EFI_SUCCESS)
- /* notify_tpl == 0: workaround for EDK2's Shell.efi */
That comment is too undescriptive. Better write something like "EDK2 accepts TPL 0 in CreateEvent, so to ensure compatibility we should do the same. EDK2 Shell.efi depends on this."
Nice!
Thanks, -Takahiro AKASHI
Alex
if (notify_tpl && (is_valid_tpl(notify_tpl) != EFI_SUCCESS)) return EFI_INVALID_PARAMETER;
evt = calloc(1, sizeof(struct efi_event));