🇰🇷 한글 설명
Linux 커널의 mm/huge_memory 구성 요소에서 mTHP 분할 작업과 zap_nonpresent_ptes() 간의 경쟁 상태(Race Condition)로 인해 folio 잠금이 제대로 확인되지 않는 취약점입니다. arm64 서버 환경에서 메모리 장벽(Memory Barrier) 누락으로 인해 tail page의 플래그가 업데이트되기 전에 접근이 발생하여 데이터 무결성 문제가 생길 수 있습니다.
💡 쉬운 설명
컴퓨터의 메모리를 관리하는 과정에서 두 가지 작업이 동시에 일어날 때, 메모리 상태를 확인하는 순서가 어긋나 발생하는 문제입니다. 이로 인해 시스템이 메모리를 잘못된 상태로 인식하여 오류가 발생하거나 불안정해질 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/huge_memory: fix folio isn't locked in softleaf_to_folio()
On arm64 server, we found folio that get from migration entry isn't locked
in softleaf_to_folio(). This issue triggers when mTHP splitting and
zap_nonpresent_ptes() races, and the root cause is lack of memory barrier
in softleaf_to_folio(). The race is as follows:
CPU0 CPU1
deferred_split_scan() zap_nonpresent_ptes()
lock folio
split_folio()
unmap_folio()
change ptes to migration entries
__split_folio_to_order() softleaf_to_folio()
set flags(including PG_locked) for tail pages folio = pfn_folio(softleaf_to_pfn(entry))
smp_wmb() VM_WARN_ON_ONCE(!folio_test_locked(folio))
prep_compound_page() for tail pages
In __split_folio_to_order(), smp_wmb() guarantees page flags of tail pages
are visible before the tail page becomes non-compound. smp_wmb() should
be paired with smp_rmb() in softleaf_to_folio(), which is missed. As a
result, if zap_nonpresent_ptes() accesses migration entry that stores tail
pfn, softleaf_to_folio() may see the updated compound_head of tail page
before page->flags.
This issue will trigger VM_WARN_ON_ONCE() in pfn_swap_entry_folio()
because of the race between folio split and zap_nonpresent_ptes()
leading to a folio incorrectly undergoing modification without a folio
lock being held.
This is a BUG_ON() before commit 93976a20345b ("mm: eliminate further
swapops predicates"), which in merged in v6.19-rc1.
To fix it, add missing smp_rmb() if the softleaf entry is migration entry
in softleaf_to_folio() and softleaf_to_page().
[
[email protected]: update function name and comments]
📍 영향받는 시스템
Linux Kernel (v6.19-rc1 미만 버전, 특히 arm64 아키텍처)
⚔️ 공격 벡터
로컬 공격자가 메모리 관리 프로세스의 경쟁 상태를 유도하여 시스템 오류를 발생시킬 수 있음
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전(v6.19-rc1 이상 또는 해당 수정사항이 포함된 배포판 버전)으로 업데이트하십시오.
🔧 검증 코드
출력된 커널 버전을 확인하여 취약점이 해결된 버전(v6.19-rc1 이상 등)인지 대조합니다.