🇰🇷 한글 설명
Linux 커널의 DAMON sysfs 구성 요소에서 리전 디렉토리 객체를 삭제할 때 연결 리스트에서 객체를 적절히 제거하지 않아 발생하는 취약점입니다. kobj 릴리스 콜백 호출이 지연될 경우 리스트에 이미 해제된 객체가 남아있게 되어, 리스트 손상 및 Use-After-Free(UAF) 오류를 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터 메모리 관리 시스템에서 이미 삭제된 정보를 목록에서 제대로 지우지 않아 발생하는 오류입니다. 이로 인해 시스템이 잘못된 메모리 주소에 접근하게 되어 시스템이 충돌하거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mm/damon/sysfs-schemes: delete tried region in regions_rmdirs()
DAMON sysfs maintains the DAMOS tried region directory objects via a
linked list. When the user requests refresh of the directories, DAMON
sysfs removes all the region directories first, and then generate updated
regions directory on the empty space. The removal function
(damon_sysfs_scheme_regions_rm_dirs()) only puts the kobj objects.
Deletion of the container region object from the linked list is done
inside the kobj release callback function.
If somehow the callback invocation is delayed, the list will contain
regions list that gonna be freed. If the updated region directories
creation is started in this situation, the list can be corrupted and
use-after-free can happen.
Because the kobj objects are managed by only DAMON sysfs, the issue cannot
happen in normal situation. But, such delays can be made on kernels that
built with CONFIG_DEBUG_KOBJECT_RELEASE. On the kernel, the issue can
indeed be reproduced like below.
# damo start --damos_action stat
# cd /sys/kernel/mm/damon/admin/kdamonds/0/
# for i in {1..10}; do echo update_schemes_tried_regions > state; done
# dmesg | grep underflow
[ 89.296152] refcount_t: underflow; use-after-free.
Fix the issue by removing the region object from the list when
decrementing the reference count.
Also update damos_sysfs_populate_region_dir() to add the region object to
the list only after the kobject_init_and_add() is success, so that fail of
kobject_init_and_add() is not leaving the deallocated object on the list.
The issue was discovered [1] by Sashiko.
📍 영향받는 시스템
Linux kernel (DAMON 기능이 활성화된 시스템, 특히 CONFIG_DEBUG_KOBJECT_RELEASE가 설정된 커널)
⚔️ 공격 벡터
사용자가 DAMON sysfs의 update_schemes_tried_regions를 반복적으로 호출하여 메모리 해제와 리스트 업데이트 간의 타이밍 차이를 유도함
🛡️ 대응 방법
커널 패치를 통해 참조 횟수 감소 시 리스트에서 객체를 즉시 제거하고, 객체 초기화 성공 후에만 리스트에 추가하도록 업데이트해야 함
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 해결된 최신 보안 패치 버전인지 확인합니다.