🇰🇷 한글 설명
Linux 커널의 HID universal-pidff 드라이버에서 포스 피드백 초기화 실패 시 장치를 중지하지 않는 취약점이 발견되었습니다. 이로 인해 장치가 해제된 후에도 hidraw 캐릭터 디바이스가 남아 있어, 해당 장치를 열려고 시도할 경우 해제된 메모리에 접근하는 Use-After-Free(UAF) 오류가 발생합니다.
💡 쉬운 설명
장치 연결 과정에서 오류가 발생했을 때 뒷정리가 제대로 되지 않아, 이미 사라진 장치를 다시 사용하려 할 때 시스템 오류가 발생하는 문제입니다. 공격자가 이를 악용하면 시스템의 메모리 영역을 조작할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
HID: universal-pidff: stop the device when force-feedback init fails
universal_pidff_probe() starts the device with hid_hw_start() and then, if
force-feedback initialisation fails, returns the error through a label that
only does "return error". The device is left started.
The HID core does not unwind on the driver's behalf. __hid_device_probe()
releases the devres group, closes the report and clears hdev->driver:
if (ret) {
devres_release_group(&hdev->dev, hdev->devres_group_id);
hid_close_report(hdev);
hdev->driver = NULL;
}
The hidraw character device that hid_hw_start() registered through
hid_connect() is allocated with kzalloc() and added with cdev_device_add(),
so it is not devres-managed and survives that. With hdev->driver NULL,
hid_device_remove() skips hid_hw_stop() as well, because it only unwinds
while a driver is still attached. The registration therefore outlives the
device on both paths.
Opening the surviving /dev/hidrawX writes into freed memory. KASAN reports
a use-after-free write from hidraw_open() -> hid_hw_open() -> the
transport's open callback, which takes a spinlock inside the freed object.
A descriptor that carries a PID usage page and no input reports is enough:
hidraw claims the device so hid_hw_start() succeeds, while hid->inputs
stays empty so force-feedback init fails. The other failure returns in
hid_pidff_init_with_quirks() - no output reports, an allocation failure,
pidff_init_fields(), pidff_check_autocenter(), an unusable effect count,
input_ff_create() - all reach the same label.
Stop the device on that path. hid-dr.c and hid-emsff.c, which start the
device with the same HID_CONNECT_DEFAULT & ~HID_CONNECT_FF mask, already do
this. The two earlier gotos must keep returning without hid_hw_stop(),
since neither has a started device, so give the path that fails after the
start its own label.
Discovered by XBOW, triaged by Baul Lee <
[email protected]>
📍 영향받는 시스템
Linux Kernel (HID universal-pidff 드라이버 포함 버전)
⚔️ 공격 벡터
특정 속성을 가진 HID 장치를 연결하여 포스 피드백 초기화 오류를 유도한 뒤, 남아있는 /dev/hidrawX 장치에 접근하여 메모리 쓰기 시도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 hid_hw_stop() 호출 로직을 포함해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인합니다.