🇰🇷 한글 설명
Linux 커널의 MTD(Memory Technology Device) 코어에서 del_mtd_device() 함수 실행 시 device_node 포인터가 메모리 초기화 이후에 해제되어 참조 카운트(refcount) 누수가 발생하는 문제입니다. 이로 인해 오버레이 노드 해제 과정에서 메모리 누수 경고가 발생합니다. 해당 포인터를 미리 캐싱하여 올바르게 해제하도록 수정되었습니다.
💡 쉬운 설명
기기의 메모리 장치를 제거할 때 내부 정보를 잘못된 순서로 지워서 사용하지 않는 메모리가 계속 남게 되는 버그입니다. 이로 인해 시스템 메모리가 점차 낭비되며, 장시간 운영 시 안정성에 영향을 줄 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mtd: core: Fix refcount error in del_mtd_device()
del_mtd_device() will call of_node_put() to mtd_get_of_node(mtd), which
is mtd->dev.of_node. However, memset(&mtd->dev, 0) is called before
of_node_put(). As the result, of_node_put() won't do anything in
del_mtd_device(), and causes the refcount leak.
del_mtd_device()
memset(&mtd->dev, 0, sizeof(mtd->dev) # clear mtd->dev
of_node_put()
mtd_get_of_node(mtd) # mtd->dev is cleared, can't locate of_node
# of_node_put(NULL) won't do anything
Fix the error by caching the pointer of the device_node.
OF: ERROR: memory leak, expected refcount 1 instead of 2,
of_node_get()/of_node_put() unbalanced - destroy cset entry: attach
overlay node /spi/spi-sram@0
CPU: 3 PID: 275 Comm: python3 Tainted: G N 6.1.0-rc3+ #54
0d8a1edddf51f172ff5226989a7565c6313b08e2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x67/0x83
kobject_get+0x155/0x160
of_node_get+0x1f/0x30
of_fwnode_get+0x43/0x70
fwnode_handle_get+0x54/0x80
fwnode_get_nth_parent+0xc9/0xe0
fwnode_full_name_string+0x3f/0xa0
device_node_string+0x30f/0x750
pointer+0x598/0x7a0
vsnprintf+0x62d/0x9b0
...
cfs_overlay_release+0x30/0x90
config_item_release+0xbe/0x1a0
config_item_put+0x5e/0x80
configfs_rmdir+0x3bd/0x540
vfs_rmdir+0x18c/0x320
do_rmdir+0x198/0x330
__x64_sys_rmdir+0x2c/0x40
do_syscall_64+0x37/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
[<
[email protected]>: Light reword of the commit log]
📍 영향받는 시스템
수정 이전 버전의 Linux 커널 (MTD 서브시스템 및 Device Tree 오버레이를 사용하는 시스템)
⚔️ 공격 벡터
로컬 사용자가 configfs를 통해 디바이스 트리 오버레이를 반복적으로 생성 및 제거하여 메모리 누수를 유발할 수 있음
🛡️ 대응 방법
커널을 해당 CVE 수정이 포함된 최신 안정 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지 또는 Linux 커널 Git 저장소의 수정 커밋과 비교하여, 패치가 포함된 버전인지 확인합니다.