🇰🇷 한글 설명
Linux 커널의 move_pages_huge_pmd() 함수에서 huge zero page 처리 시 NULL folio가 잘못 사용되어 존재하지 않는 물리 메모리를 가리키는 PMD가 설치되거나 NULL 역참조 발생. 이동된 PMD가 특수 매핑 표시를 잃으면서 페이지 참조 카운트가 손상될 수 있음.
💡 쉬운 설명
Linux 커널이 특정 메모리 이동 작업에서 잘못된 메모리 위치를 가리키는 버그로, 로컬 공격자가 userfaultfd API를 악용하면 시스템 충돌이나 메모리 손상을 유발할 수 있음.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/huge_memory: fix use of NULL folio in move_pages_huge_pmd()
move_pages_huge_pmd() handles UFFDIO_MOVE for both normal THPs and huge
zero pages. For the huge zero page path, src_folio is explicitly set to
NULL, and is used as a sentinel to skip folio operations like lock and
rmap.
In the huge zero page branch, src_folio is NULL, so folio_mk_pmd(NULL,
pgprot) passes NULL through folio_pfn() and page_to_pfn(). With
SPARSEMEM_VMEMMAP this silently produces a bogus PFN, installing a PMD
pointing to non-existent physical memory. On other memory models it is a
NULL dereference.
Use page_folio(src_page) to obtain the valid huge zero folio from the
page, which was obtained from pmd_page() and remains valid throughout.
After commit d82d09e48219 ("mm/huge_memory: mark PMD mappings of the huge
zero folio special"), moved huge zero PMDs must remain special so
vm_normal_page_pmd() continues to treat them as special mappings.
move_pages_huge_pmd() currently reconstructs the destination PMD in the
huge zero page branch, which drops PMD state such as pmd_special() on
architectures with CONFIG_ARCH_HAS_PTE_SPECIAL. As a result,
vm_normal_page_pmd() can treat the moved huge zero PMD as a normal page
and corrupt its refcount.
Instead of reconstructing the PMD from the folio, derive the destination
entry from src_pmdval after pmdp_huge_clear_flush(), then handle the PMD
metadata the same way move_huge_pmd() does for moved entries by marking it
soft-dirty and clearing uffd-wp.
📍 영향받는 시스템
Linux kernel (d82d09e48219 커밋 이후 UFFDIO_MOVE 기능을 지원하는 모든 버전)
⚔️ 공격 벡터
로컬 사용자가 userfaultfd를 통해 UFFDIO_MOVE 메모리 이동 작업을 수행할 때 트리거되는 메모리 관리 버그
🛡️ 대응 방법
Linux 커널을 move_pages_huge_pmd() 수정 사항이 포함된 최신 버전으로 업데이트
🔧 검증 코드
커널 버전을 확인하여 배포판 보안 공지에서 제시한 패치 버전 이상인지 검증
cat /proc/version | grep -oE 'Linux version [^ ]+'