In the Linux kernel, the following vulnerability has been resolved: x86/efi: defer freeing of boot services memory efifreebootservices() frees memory occupied by EFIBOOTSERVICESCODE and EFIBOOTSERVICESDATA using memblockfreelate(). There are two issue with that: memblockfreelate() should be used for memory allocated with memblockalloc() while the memory reserved with memblockreserve() should be freed with freereservedarea(). More acutely, with CONFIGDEFERREDSTRUCTPAGEINIT=y efifreebootservices() is called before deferred initialization of the memory map is complete. Benjamin Herrenschmidt reports that this causes a leak of ~140MB of RAM on EC2 t3a.nano instances which only have 512MB or RAM. If the freed memory resides in the areas that memory map for them is still uninitialized, they won't be actually freed because memblockfreelate() calls memblockfreepages() and the latter skips uninitialized pages. Using freereservedarea() at this point is also problematic because _freepage() accesses the buddy of the freed page and that again might end up in uninitialized part of the memory map. Delaying the entire efifreebootservices() could be problematic because in addition to freeing boot services memory it updates efi.memmap without any synchronization and that's undesirable late in boot when there is concurrency. More robust approach is to only defer freeing of the EFI boot services memory. Split efifreebootservices() in two. First efiunmapbootservices() collects ranges that should be freed into an array then efifreebootservices() later frees them after deferred init is complete.