🇰🇷 한글 설명
Linux 커널의 MGLRU(Multi-Gen LRU) 관리 과정에서 unevictable folio(축출 불가능한 폴리오)를 처리하는 sort_folio() 함수에 버그가 발견되었습니다. 이 버그는 mlock_count를 잘못된 값으로 설정하여 메모리 잠금 해제가 제대로 이루어지지 않게 하며, LRU 플래그를 잘못된 순서로 조작하여 예기치 않은 동작을 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터 메모리를 관리하는 과정에서 특정 데이터가 메모리에서 나가지 못하도록 잠기는 기능에 오류가 발생했습니다. 이로 인해 메모리 사용량이 실제보다 높게 표시되거나 시스템이 비효율적으로 동작할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/mglru: fix and remove redundant unevictable folio handling
sort_folio() has a shortcut for moving folios that are no longer evictable
but are still sitting on a generation list. However, this shortcut is
buggy. It does not follow the PG_lru usage convention, and it has a more
serious issue.
Unevictable folios are not threaded on lists[LRU_UNEVICTABLE], so that
folio->lru can be reused to hold folio->mlock_count (see the comment in
lruvec_init()). Hence lruvec_add_folio() skips the list_add() for them,
and every other place that turns a folio unevictable initialises
mlock_count explicitly: lru_add() sets it to 0, __mlock_folio() and
__mlock_new_folio() set it to !!folio_test_mlocked(folio). sort_folio()
sets nothing, and the lru_gen_del_folio() right above it may have already
poisoned folio->lru via list_del(), so mlock_count ends up aliasing
LIST_POISON2, which reads as 0x122, i.e. 290. The result is user
visible. On munlock, __munlock_folio() decrements that bogus count, finds
it still non-zero and bails out before clearing PG_mlocked, so the folio
remains unevictable and the Mlocked accounting stays inflated until the
folio is freed.
The shortcut also touches the LRU flags in the wrong order. It calls
lru_gen_del_folio() while PG_lru is still set, so a concurrent
folio_test_clear_lru() (e.g. compaction, folio_isolate_lru()) can succeed
on a folio that has already been taken off the generation list, which may
lead to unexpected behavior.
So fix it by isolating them as common folios and letting the generic
shrink path cull them. This matches the classical LRU behavior, and there
should be no visible effect on the generic eviction or isolation behavior.
There is no performance concern either, such a folio goes through this
once, and then it is off the generation lists for good.
📍 영향받는 시스템
Linux kernel (MGLRU 기능이 활성화된 버전)
⚔️ 공격 벡터
로컬 공격자가 메모리 잠금(mlock)을 반복적으로 수행하여 메모리 계정 오류를 유발할 수 있음
🛡️ 대응 방법
MGLRU 관련 수정 사항이 포함된 최신 Linux 커널로 업데이트하십시오.
🔧 검증 코드
출력된 커널 버전이 MGLRU 취약점이 패치된 최신 버전인지 확인하십시오.