Skip to content

Close uefi protocols after usage

Khalid Ali grub-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2efi: Add wrappers to close device path and loaded imagegrub-core/kern/efi/efi.c include/grub/efi/efi.h+15 -00 replies
2/2efi: Always close protocols after usagegrub-core/commands/bli.c grub-core/commands/efi/lsefi.c grub-core/commands/efi/tpm.c +9 more+25 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Close uefi protocols after usage

From: Khalid Ali <[email protected]>

Currently, Grub when it opens a protocol with OpenProtocol() UEFI services it doesn't close those protocols, this causes internal firmware resources used and allocated by OpenPrototcol() to get leaked.

As per UEFI spec after OpenProtocol() is called and protocol is finished with usage the caller should call CloseProtocol () to free firmware resource and update global databases.

Grub currently has assumption that ExitBootService () will free resources, however it is not granteed to do so. Also, if grub fails it may call Exit () boot services to return to firmware, however in that case then firmware resources will be leaked. On tianocore edk2, this considered a bug and already were serveral patches.

To prevent that, Grub should always close opened protocols after there usage is finished.

This patch set resolves that by calling CloseProtocol () always after protocol is used. Also, it is added two wrappers to close device path and loaded image protocol the opposite of wrappers opened the two protocols.

References of open issues and patches for tianocore edk2 (the upstream reference of UEFI implementation):
Issue: https://github.com/tianocore/edk2/issues/11110

Khalid Ali (2):
efi: Add wrappers to close device path and loaded image
efi: Always close protocols after usage

 grub-core/commands/bli.c           |  1 +
 grub-core/commands/efi/lsefi.c     |  1 +
 grub-core/commands/efi/tpm.c       |  5 +++--
 grub-core/disk/efi/efidisk.c       |  3 +++
 grub-core/kern/efi/efi.c           | 13 +++++++++++++
 grub-core/kern/efi/init.c          |  1 +
 grub-core/loader/efi/appleloader.c |  2 +-
 grub-core/loader/efi/chainloader.c |  5 +++--
 grub-core/loader/efi/linux.c       |  1 +
 grub-core/net/drivers/efi/efinet.c |  6 ++++++
 grub-core/term/efi/console.c       |  2 +-
 grub-core/term/efi/serial.c        |  1 +
 grub-core/video/efi_gop.c          |  4 +++-
 include/grub/efi/efi.h             |  2 ++
 14 files changed, 40 insertions(+), 7 deletions(-)
Signature · 7 lines
2.52.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel