🇰🇷 한글 설명
Linux 커널의 x86/efi 구성에서 부트 서비스 메모리 해제 방식의 오류로 인해 메모리 누수가 발생합니다. 특정 설정(CONFIG_DEFERRED_STRUCT_PAGE_INIT=y) 환경에서 메모리 맵 초기화가 완료되기 전에 메모리를 해제하려 시도하여 약 140MB의 RAM이 해제되지 않고 누수되는 문제가 있습니다.
💡 쉬운 설명
컴퓨터가 켜질 때 사용한 임시 메모리를 정리하는 과정에서 실수가 발생하여, 실제로는 사용 가능한 메모리인데도 시스템이 이를 인식하지 못하고 버리는 현상입니다. 특히 메모리 용량이 작은 환경에서는 시스템 성능 저하나 메모리 부족 문제를 일으킬 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
x86/efi: defer freeing of boot services memory
efi_free_boot_services() frees memory occupied by EFI_BOOT_SERVICES_CODE
and EFI_BOOT_SERVICES_DATA using memblock_free_late().
There are two issue with that: memblock_free_late() should be used for
memory allocated with memblock_alloc() while the memory reserved with
memblock_reserve() should be freed with free_reserved_area().
More acutely, with CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
efi_free_boot_services() 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
memblock_free_late() calls memblock_free_pages() and the latter skips
uninitialized pages.
Using free_reserved_area() at this point is also problematic because
__free_page() accesses the buddy of the freed page and that again might
end up in uninitialized part of the memory map.
Delaying the entire efi_free_boot_services() 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 efi_free_boot_services() in two. First efi_unmap_boot_services()
collects ranges that should be freed into an array then
efi_free_boot_services() later frees them after deferred init is complete.
📍 영향받는 시스템
Linux kernel (x86/efi architecture, CONFIG_DEFERRED_STRUCT_PAGE_INIT=y enabled)
⚔️ 공격 벡터
Local (메모리 누수로 인한 서비스 거부 또는 자원 고갈 유도 가능)
🛡️ 대응 방법
커널을 최신 패치가 적용된 버전으로 업데이트하여 efi_free_boot_services() 함수가 메모리 맵 초기화 완료 후 실행되도록 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인합니다.