🇰🇷 한글 설명
Linux 커널의 hwmon(corsair-psu) 드라이버에서 hid_hw_stop() 호출 전 장치 IO를 중단하지 않아 발생하는 레이스 컨디션 취약점입니다. 이로 인해 probe 작업 실패 시 hidraw 객체에 대한 Use-After-Free(UAF)가 발생할 수 있습니다.
💡 쉬운 설명
장치를 준비하는 과정에서 오류가 발생했을 때, 장치와의 통신을 완전히 끊지 않고 메모리를 먼저 삭제하여 발생하는 문제입니다. 이로 인해 시스템이 잘못된 메모리 주소에 접근하여 충돌하거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
hwmon: (corsair-psu) Stop device IO before calling hid_hw_stop
hid_hw_stop() does not stop the device IO.
This results in a race condition between hid_input_report() and the point
immediately following the execution of hid_device_io_start() within
corsairpsu_probe(). If the probe operation fails after "io start" has
been initiated, this race condition will result in a uaf vulnerability
[1].
CPU0 CPU1
==== ====
corsairpsu_probe()
hid_device_io_start()
... unlock driver_input_lock
hid_hw_stop()
kfree(hidraw) __hid_input_report()
... acquire driver_input_lock
hid_report_raw_event()
hidraw_report_event()
... access hidraw's list_lock // trigger uaf
Consequently, when corsairpsu_probe() fails and hid_hw_stop() needs to
be executed, the io_started flag is first cleared while holding the
driver_input_lock to prevent potential race conditions involving input
reports.
[1]
BUG: KASAN: slab-use-after-free in rt_spin_lock+0x83/0x400 kernel/locking/spinlock_rt.c:56
Call Trace:
hidraw_report_event+0x5d/0x3a0 drivers/hid/hidraw.c:577
hid_report_raw_event+0x311/0x1730 drivers/hid/hid-core.c:2076
__hid_input_report drivers/hid/hid-core.c:2152 [inline]
hid_input_report+0x44e/0x580 drivers/hid/hid-core.c:2174
hid_irq_in+0x47e/0x6d0 drivers/hid/usbhid/hid-core.c:286
__usb_hcd_giveback_urb+0x3b3/0x5e0 drivers/usb/core/hcd.c:1657
dummy_timer+0x8a9/0x47d0 drivers/usb/gadget/udc/dummy_hcd.c:2005
Allocated by task 10:
hidraw_connect+0x57/0x430 drivers/hid/hidraw.c:606
hid_connect+0x5bf/0x19d0 drivers/hid/hid-core.c:2277
hid_hw_start+0xa8/0x120 drivers/hid/hid-core.c:2387
corsairpsu_probe+0xd9/0x3c0 drivers/hwmon/corsair-psu.c:782
Freed by task 10:
hidraw_disconnect+0x4f/0x60 drivers/hid/hidraw.c:662
hid_disconnect drivers/hid/hid-core.c:2362 [inline]
hid_hw_stop+0x101/0x1e0 drivers/hid/hid-core.c:2407
corsairpsu_probe+0x327/0x3c0 drivers/hwmon/corsair-psu.c:826
Fix the problem by calling hid_device_io_stop() before calling
hid_hw_stop().
[groeck: Updated subject and description;
call hid_device_io_stop() only if IO has been started]
📍 영향받는 시스템
Linux kernel (corsair-psu driver 포함 버전)
⚔️ 공격 벡터
장치 프로브(probe) 과정에서 의도적인 오류를 유도하여 레이스 컨디션을 통한 Use-After-Free 유발
🛡️ 대응 방법
hid_hw_stop()을 호출하기 전에 hid_device_io_stop()을 호출하도록 커널 패치 적용
🔧 검증 코드
커널 버전과 corsair-psu 모듈 정보를 확인하여 해당 취약점이 수정된 최신 커널인지 확인합니다.
uname -r && modinfo corsair-psu 2>/dev/null