🇰🇷 한글 설명
Linux 커널의 USB gadget composite 드라이버에서 USB_DT_OTG 핸들러의 잘못된 빈 리스트 체크로 인해 발생하는 취약점입니다. 리스트가 비어있을 때 NULL을 반환하지 않는 함수 사용으로 인해 잘못된 메모리 영역을 참조하여 KASAN 결함이나 메모리 손상을 유발할 수 있습니다.
💡 쉬운 설명
USB 연결을 처리하는 과정에서 데이터가 비어있는지 확인하는 코드가 제대로 작동하지 않아 발생합니다. 이로 인해 컴퓨터가 잘못된 메모리 주소를 읽으려다가 시스템 오류가 발생하거나 멈출 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: composite: fix dead empty check in the USB_DT_OTG handler
The OTG branch of composite_setup() falls back to the first
configuration when none is selected:
if (cdev->config)
config = cdev->config;
else
config = list_first_entry(&cdev->configs,
struct usb_configuration, list);
if (!config)
goto done;
...
memcpy(req->buf, config->descriptors[0], value);
list_first_entry() never returns NULL. On an empty list it returns
container_of() of the list head. So the "if (!config)" check is dead.
When cdev->configs is empty, config points at the head inside struct
usb_composite_dev. config->descriptors[0] reads whatever sits at that
offset. The memcpy copies up to w_length bytes of it into the response
buffer.
cdev->configs can be empty in two cases. One is a teardown race on
gadget unbind with a control transfer in flight. The other is a driver
that sets is_otg before it adds a config. A reproducer that holds
cdev->configs empty triggers a KASAN fault in this branch.
Use list_first_entry_or_null() so the existing check does its job.
📍 영향받는 시스템
USB Gadget Composite 기능을 사용하는 Linux 커널 버전
⚔️ 공격 벡터
USB 장치 해제 시 발생하는 레이스 컨디션 또는 특정 드라이버 설정을 이용한 메모리 오버리드 유도
🛡️ 대응 방법
list_first_entry() 대신 list_first_entry_or_null()을 사용하도록 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 패치 버전인지 확인