🇰🇷 한글 설명
Linux 커널의 md(Multiple Device) 드라이버에서 array_state를 'clear'로 설정할 때 sysfs 데드락이 발생하는 취약점입니다. md_attr_store() 함수가 mddev 참조를 해제하기 전에 sysfs 보호를 해제하여, kobject 삭제 과정에서 재귀적 잠금(recursive locking)이 발생할 수 있습니다.
💡 쉬운 설명
리눅스 시스템에서 저장 장치 설정을 초기화할 때, 시스템 내부의 잠금 메커니즘이 꼬여서 컴퓨터가 멈추거나 오류가 발생할 수 있는 문제입니다. 특정 명령어를 통해 저장 장치 상태를 변경할 때 시스템의 관리 기능이 충돌을 일으킵니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
md: fix array_state=clear sysfs deadlock
When "clear" is written to array_state, md_attr_store() breaks sysfs
active protection so the array can delete itself from its own sysfs
store method.
However, md_attr_store() currently drops the mddev reference before
calling sysfs_unbreak_active_protection(). Once do_md_stop(..., 0)
has made the mddev eligible for delayed deletion, the temporary
kobject reference taken by sysfs_break_active_protection() can become
the last kobject reference protecting the md kobject.
That allows sysfs_unbreak_active_protection() to drop the last
kobject reference from the current sysfs writer context. kobject
teardown then recurses into kernfs removal while the current sysfs
node is still being unwound, and lockdep reports recursive locking on
kn->active with kernfs_drain() in the call chain.
Reproducer on an existing level:
1. Create an md0 linear array and activate it:
mknod /dev/md0 b 9 0
echo none > /sys/block/md0/md/metadata_version
echo linear > /sys/block/md0/md/level
echo 1 > /sys/block/md0/md/raid_disks
echo "$(cat /sys/class/block/sdb/dev)" > /sys/block/md0/md/new_dev
echo "$(($(cat /sys/class/block/sdb/size) / 2))" > \
/sys/block/md0/md/dev-sdb/size
echo 0 > /sys/block/md0/md/dev-sdb/slot
echo active > /sys/block/md0/md/array_state
2. Wait briefly for the array to settle, then clear it:
sleep 2
echo clear > /sys/block/md0/md/array_state
The warning looks like:
WARNING: possible recursive locking detected
bash/588 is trying to acquire lock:
(kn->active#65) at __kernfs_remove+0x157/0x1d0
but task is already holding lock:
(kn->active#65) at sysfs_unbreak_active_protection+0x1f/0x40
...
Call Trace:
kernfs_drain
__kernfs_remove
kernfs_remove_by_name_ns
sysfs_remove_group
sysfs_remove_groups
__kobject_del
kobject_put
md_attr_store
kernfs_fop_write_iter
vfs_write
ksys_write
Restore active protection before mddev_put() so the extra sysfs
kobject reference is dropped while the mddev is still held alive. The
actual md kobject deletion is then deferred until after the sysfs
write path has fully returned.
📍 영향받는 시스템
Linux kernel (md driver 사용 시스템)
⚔️ 공격 벡터
로컬 사용자가 sysfs 인터페이스를 통해 md array의 array_state를 'clear'로 변경할 때 발생
🛡️ 대응 방법
md_attr_store()에서 mddev_put() 호출 전에 sysfs_unbreak_active_protection()을 호출하도록 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 최신 패치 버전인지 확인하십시오.