🇰🇷 한글 설명
Linux 커널의 hugetlb 파일 folio 처리 과정에서 잠금 순서(lock ordering) 오류로 인해 데드락(Deadlock)이 발생할 수 있는 취약점입니다. 페이지 이동(migrate) 작업과 파일 할당(fallocate) 작업이 서로 다른 순서로 자원을 점유하려고 시도하면서 시스템이 멈출 수 있습니다.
💡 쉬운 설명
컴퓨터의 메모리를 관리하는 과정에서 두 작업이 서로 상대방이 가진 자원을 기다리며 무한히 대기하는 상태가 발생할 수 있습니다. 이로 인해 시스템이 응답하지 않거나 멈추는 현상이 나타날 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
migrate: correct lock ordering for hugetlb file folios
Syzbot has found a deadlock (analyzed by Lance Yang):
1) Task (5749): Holds folio_lock, then tries to acquire i_mmap_rwsem(read lock).
2) Task (5754): Holds i_mmap_rwsem(write lock), then tries to acquire
folio_lock.
migrate_pages()
-> migrate_hugetlbs()
-> unmap_and_move_huge_page() <- Takes folio_lock!
-> remove_migration_ptes()
-> __rmap_walk_file()
-> i_mmap_lock_read() <- Waits for i_mmap_rwsem(read lock)!
hugetlbfs_fallocate()
-> hugetlbfs_punch_hole() <- Takes i_mmap_rwsem(write lock)!
-> hugetlbfs_zero_partial_page()
-> filemap_lock_hugetlb_folio()
-> filemap_lock_folio()
-> __filemap_get_folio <- Waits for folio_lock!
The migration path is the one taking locks in the wrong order according to
the documentation at the top of mm/rmap.c. So expand the scope of the
existing i_mmap_lock to cover the calls to remove_migration_ptes() too.
This is (mostly) how it used to be after commit c0d0381ade79. That was
removed by 336bf30eb765 for both file & anon hugetlb pages when it should
only have been removed for anon hugetlb pages.
📍 영향받는 시스템
Linux Kernel (hugetlb 관련 기능이 활성화된 버전)
⚔️ 공격 벡터
특정 메모리 관리 작업(페이지 이동 및 파일 할당)을 유도하여 시스템 데드락 유발
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 잠금 순서 수정 사항 반영
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인