From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Date: Thu, 9 Aug 2018 07:55:06 +0100 Subject: [U-Boot] [RFC] efi_loader: workaround for EDK2's shell.efi In-Reply-To: <20180809061538.6624-1-takahiro.akashi@linaro.org> References: <20180809061538.6624-1-takahiro.akashi@linaro.org> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 :). 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. > The patch provides a minimum mitigation of parameter check. > > Signed-off-by: AKASHI Takahiro > --- > 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." Alex > + if (notify_tpl && (is_valid_tpl(notify_tpl) != EFI_SUCCESS)) > return EFI_INVALID_PARAMETER; > > evt = calloc(1, sizeof(struct efi_event)); >