🇰🇷 한글 설명
Linux 커널 ext4 파일시스템의 extent 삽입 함수(ext4_ext_insert_extent)에서 경로 재할당 시 use-after-free 취약점이 발생합니다. ext4_ext_create_new_leaf() 함수 호출 후 경로 포인터가 재할당되지만 기존 포인터가 계속 사용되어 해제된 메모리에 접근하게 됩니다.
💡 쉬운 설명
파일을 쓸 때 시스템이 메모리 주소를 재배치하는데, 예전 주소를 계속 참조하여 이미 해제된 메모리에 접근합니다. 이는 커널 패닉이나 권한 상승을 야기할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ext4: aovid use-after-free in ext4_ext_insert_extent()
As Ojaswin mentioned in Link, in ext4_ext_insert_extent(), if the path is
reallocated in ext4_ext_create_new_leaf(), we'll use the stale path and
cause UAF. Below is a sample trace with dummy values:
ext4_ext_insert_extent
path = *ppath = 2000
ext4_ext_create_new_leaf(ppath)
ext4_find_extent(ppath)
path = *ppath = 2000
if (depth > path[0].p_maxdepth)
kfree(path = 2000);
*ppath = path = NULL;
path = kcalloc() = 3000
*ppath = 3000;
return path;
/* here path is still 2000, UAF! */
eh = path[depth].p_hdr
==================================================================
BUG: KASAN: slab-use-after-free in ext4_ext_insert_extent+0x26d4/0x3330
Read of size 8 at addr ffff8881027bf7d0 by task kworker/u36:1/179
CPU: 3 UID: 0 PID: 179 Comm: kworker/u6:1 Not tainted 6.11.0-rc2-dirty #866
Call Trace:
<TASK>
ext4_ext_insert_extent+0x26d4/0x3330
ext4_ext_map_blocks+0xe22/0x2d40
ext4_map_blocks+0x71e/0x1700
ext4_do_writepages+0x1290/0x2800
[...]
Allocated by task 179:
ext4_find_extent+0x81c/0x1f70
ext4_ext_map_blocks+0x146/0x2d40
ext4_map_blocks+0x71e/0x1700
ext4_do_writepages+0x1290/0x2800
ext4_writepages+0x26d/0x4e0
do_writepages+0x175/0x700
[...]
Freed by task 179:
kfree+0xcb/0x240
ext4_find_extent+0x7c0/0x1f70
ext4_ext_insert_extent+0xa26/0x3330
ext4_ext_map_blocks+0xe22/0x2d40
ext4_map_blocks+0x71e/0x1700
ext4_do_writepages+0x1290/0x2800
ext4_writepages+0x26d/0x4e0
do_writepages+0x175/0x700
[...]
==================================================================
So use *ppath to update the path to avoid the above problem.
📍 영향받는 시스템
Linux kernel 6.11.0-rc2 이전 버전의 ext4 파일시스템 (특히 writepages 작업 중)
⚔️ 공격 벡터
ext4 파일시스템에서 대용량 파일 쓰기 작업 또는 extent 매핑 재구성 시 자동 트리거 가능 (로컬 권한 필요)
🛡️ 대응 방법
Linux 커널을 CVE-2024-49883 패치가 포함된 최신 버전으로 업데이트
🔧 검증 코드
커널 버전이 6.11.0-rc2 이상이고 2024년 10월 이후 빌드 날짜라면 패치됨. 이전 버전은 취약함.
uname -r | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' && cat /proc/version