🇰🇷 한글 설명
Linux 커널의 메모리 마이그레이션 과정에서 대상 페이지의 mapping 필드에 anon_vma 포인터만 저장되고 PAGE_MAPPING_ANON 플래그가 설정되지 않아, 메모리 핫플러그 중 page_mapping()이 잘못된 파일 매핑을 반환하여 커널 NULL 포인터 역참조가 발생할 수 있습니다. 해당 수정은 anon_vma 포인터와 페이지 상태 비트를 page->private 필드에 저장하는 방식으로 이루어졌습니다.
💡 쉬운 설명
컴퓨터가 메모리를 옮기는 작업과 메모리를 끄는 작업이 동시에 일어날 때 잘못된 정보를 읽어 시스템이 멈출 수 있는 문제입니다. 커널이 메모리 페이지의 종류를 잘못 판단하는 것이 원인입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm: migrate: fix getting incorrect page mapping during page migration
When running stress-ng testing, we found below kernel crash after a few hours:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
pc : dentry_name+0xd8/0x224
lr : pointer+0x22c/0x370
sp : ffff800025f134c0
......
Call trace:
dentry_name+0xd8/0x224
pointer+0x22c/0x370
vsnprintf+0x1ec/0x730
vscnprintf+0x2c/0x60
vprintk_store+0x70/0x234
vprintk_emit+0xe0/0x24c
vprintk_default+0x3c/0x44
vprintk_func+0x84/0x2d0
printk+0x64/0x88
__dump_page+0x52c/0x530
dump_page+0x14/0x20
set_migratetype_isolate+0x110/0x224
start_isolate_page_range+0xc4/0x20c
offline_pages+0x124/0x474
memory_block_offline+0x44/0xf4
memory_subsys_offline+0x3c/0x70
device_offline+0xf0/0x120
......
After analyzing the vmcore, I found this issue is caused by page migration.
The scenario is that, one thread is doing page migration, and we will use the
target page's ->mapping field to save 'anon_vma' pointer between page unmap and
page move, and now the target page is locked and refcount is 1.
Currently, there is another stress-ng thread performing memory hotplug,
attempting to offline the target page that is being migrated. It discovers that
the refcount of this target page is 1, preventing the offline operation, thus
proceeding to dump the page. However, page_mapping() of the target page may
return an incorrect file mapping to crash the system in dump_mapping(), since
the target page->mapping only saves 'anon_vma' pointer without setting
PAGE_MAPPING_ANON flag.
There are seveval ways to fix this issue:
(1) Setting the PAGE_MAPPING_ANON flag for target page's ->mapping when saving
'anon_vma', but this can confuse PageAnon() for PFN walkers, since the target
page has not built mappings yet.
(2) Getting the page lock to call page_mapping() in __dump_page() to avoid crashing
the system, however, there are still some PFN walkers that call page_mapping()
without holding the page lock, such as compaction.
(3) Using target page->private field to save the 'anon_vma' pointer and 2 bits
page state, just as page->mapping records an anonymous page, which can remove
the page_mapping() impact for PFN walkers and also seems a simple way.
So I choose option 3 to fix this issue, and this can also fix other potential
issues for PFN walkers, such as compaction.
📍 영향받는 시스템
Linux 커널 패치 이전 버전 (메모리 마이그레이션 및 메모리 핫플러그 기능을 사용하는 시스템)
⚔️ 공격 벡터
로컬 사용자가 메모리 핫플러그와 페이지 마이그레이션을 동시에 유발하는 부하를 생성하여 커널 패닉(서비스 거부)을 일으킬 수 있음
🛡️ 대응 방법
배포판 제공 최신 커널 업데이트를 적용하거나 해당 커밋이 포함된 커널로 업그레이드
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지에서 해당 CVE 수정이 포함된 패치 버전과 비교하여, 같거나 높으면 수정됨, 낮으면 업데이트 필요