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(-) -- 2.52.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
