🇰🇷 한글 설명
Linux 커널의 mm/rmap 구성 요소에서 try_to_unmap_one 함수 호출 시 nr_pages 변수가 루프 시작 시 적절히 초기화되지 않는 취약점입니다. 이로 인해 이전 루프의 값이 재사용되어 folio의 refcount 또는 mapcount가 손상될 수 있으며, 결과적으로 커널 충돌을 유발합니다.
💡 쉬운 설명
컴퓨터의 메모리를 관리하는 과정에서 숫자를 계산하는 방식에 오류가 있어, 잘못된 숫자가 사용될 수 있는 문제입니다. 이 오류가 발생하면 시스템이 갑자기 멈추거나 꺼지는 현상이 나타날 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/rmap: initialize nr_pages to 1 at loop start in try_to_unmap_one
Initialize nr_pages to 1 at the start of each loop iteration, like
folio_referenced_one() does.
Without this, nr_pages computed by a previous folio_unmap_pte_batch() call
can be reused on a later iteration that does not run
folio_unmap_pte_batch() again.
mmap a 64K large folio with MAP_ANONYMOUS | MAP_DROPPABLE, then call
madvise(MADV_FREE), then make the last page device-exclusive via
HMM_DMIRROR_EXCLUSIVE.
Trigger node reclaim through sysfs. Now, in try_to_unmap_one(), we will
first clear the first 15 out of 16 entries mapping the lazyfree folio.
This will set nr_pages to 15. In the next pvmw walk, this nr_pages gets
reused on a device-exclusive pte, thus potentially corrupting folio
refcount/mapcount.
At the moment, I have a userspace program which can make the kernel spit
out a trace, but the blow up is in folio_referenced_one(), because there
are existing bugs in the interaction between device-private and rmap
(which too I am investigating). I did a one liner kernel change to avoid
going into folio_referenced_one(), and the kernel blows up at
folio_remove_rmap_ptes in try_to_unmap_one which is what I wanted.
Note that the bug is there not since file folio batching but lazyfree
folio batching, since device-exclusive only works for anonymous folios.
Userspace visible effect is simply kernel crashing somewhere due to
refcount/mapcount corruption.
📍 영향받는 시스템
Linux Kernel (mm/rmap 관련 기능이 포함된 버전)
⚔️ 공격 벡터
특정 메모리 매핑(MAP_ANONYMOUS, MAP_DROPPABLE) 및 HMM 장치 독점 설정을 이용한 로컬 공격
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 try_to_unmap_one 함수의 nr_pages 초기화 로직을 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인합니다.