🇰🇷 한글 설명
Linux 커널의 interconnect 서브시스템에서 icc_get() 및 of_icc_get_by_index() 함수 호출 시 메모리 해제 후 재사용(Use-After-Free) 취약점이 발견되었습니다. kasprintf()를 통한 동적 할당 실패 시, 이미 연결된 리스트를 적절히 해제하지 않고 메모리를 직접 해제하여 dangling pointer를 생성합니다. 이로 인해 이후 리스트 탐색 시 커널 패닉이나 임의 코드 실행이 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터의 핵심 부품들을 연결하는 통로를 관리하는 과정에서, 메모리를 정리할 때 연결 고리를 끊지 않고 메모리만 먼저 버리는 실수가 있었습니다. 이 때문에 나중에 컴퓨터가 끊어진 연결 고리를 다시 찾으려 할 때 시스템이 멈추거나 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
interconnect: Fix use after free in icc_get() and of_icc_get_by_index()
In of_icc_get_by_index() and icc_get(), if the dynamic allocation for
path->name fails via kasprintf(), the error handling path directly
calls kfree(path) to free the path object and returns an error.
However, prior to this point, path_find() calls path_init(), which
already links the path's requests into the req_list of the respective
interconnect nodes via hlist_add_head(). Directly invoking kfree(path)
leaves dangling pointers in the hlist. A subsequent call to icc_get()
or icc_set_bw() will traverse or modify these corrupted lists, triggering
a slab use afterfree.
KASAN report showing the vulnerability when reproducing via debugfs:
BUG: KASAN: slab-use-after-free in path_find+0x6f8/0xcfc
Write of size 8 at addr fff000000d43f748 by task sh/1
...
Call trace:
kasan_report+0xac/0xfc
path_find+0x6f8/0xcfc
icc_get+0x148/0x380
icc_get_set+0xf8/0x2d0
...
Freed by task 1:
kfree+0x1a0/0x4a4
icc_get+0x2cc/0x380
icc_get_set+0xf8/0x2d0
Fix this by replacing kfree(path) with the proper teardown function,
icc_put(path), which safely removes the requests from the req_list using
hlist_del() and drops the provider usage references before freeing the
memory.
Additionally, in icc_get(), ensure that the icc_lock mutex is released
prior to calling icc_put(path) to avoid a deadlock, as icc_put()
internally acquires the same lock.
📍 영향받는 시스템
Linux Kernel (interconnect subsystem 관련 버전)
⚔️ 공격 벡터
메모리 할당 실패를 유도하거나 특정 인터커넥트 경로를 조작하여 커널 메모리 오염 유발
🛡️ 대응 방법
kfree(path) 대신 리스트를 안전하게 제거하는 icc_put(path)를 사용하고, 데드락 방지를 위해 뮤텍스 해제 로직을 적용한 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 패치 버전인지 확인