🇰🇷 한글 설명
Linux 커널의 dwc3 드라이버에서 dwc3_remove_requests() 호출 경로 간의 동기화되지 않은 실행으로 인해 레이스 컨디션이 발생합니다. 이로 인해 USB 요청이 조기에 해제되어 Use-After-Free(UAF) 상태가 유발되고 시스템 크래시가 발생할 수 있습니다.
💡 쉬운 설명
USB 장치를 연결하거나 해제하는 과정에서 여러 작업이 동시에 처리될 때, 이미 삭제된 메모리에 접근하려고 시도하여 시스템이 멈추거나 꺼질 수 있는 문제입니다. 특정 상황에서 데이터 처리 순서가 꼬이면서 발생하는 오류입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
usb: dwc3: Fix race condition between concurrent dwc3_remove_requests() call paths
This patch addresses a race condition caused by unsynchronized
execution of multiple call paths invoking `dwc3_remove_requests()`,
leading to premature freeing of USB requests and subsequent crashes.
Three distinct execution paths interact with `dwc3_remove_requests()`:
Path 1:
Triggered via `dwc3_gadget_reset_interrupt()` during USB reset
handling. The call stack includes:
- `dwc3_ep0_reset_state()`
- `dwc3_ep0_stall_and_restart()`
- `dwc3_ep0_out_start()`
- `dwc3_remove_requests()`
- `dwc3_gadget_del_and_unmap_request()`
Path 2:
Also initiated from `dwc3_gadget_reset_interrupt()`, but through
`dwc3_stop_active_transfers()`. The call stack includes:
- `dwc3_stop_active_transfers()`
- `dwc3_remove_requests()`
- `dwc3_gadget_del_and_unmap_request()`
Path 3:
Occurs independently during `adb root` execution, which triggers
USB function unbind and bind operations. The sequence includes:
- `gserial_disconnect()`
- `usb_ep_disable()`
- `dwc3_gadget_ep_disable()`
- `dwc3_remove_requests()` with `-ESHUTDOWN` status
Path 3 operates asynchronously and lacks synchronization with Paths
1 and 2. When Path 3 completes, it disables endpoints and frees 'out'
requests. If Paths 1 or 2 are still processing these requests,
accessing freed memory leads to a crash due to use-after-free conditions.
To fix this added check for request completion and skip processing
if already completed and added the request status for ep0 while queue.
📍 영향받는 시스템
dwc3 드라이버를 사용하는 Linux 커널 기반 시스템 (USB Gadget 모드 사용 시)
⚔️ 공격 벡터
USB 리셋 또는 ADB root 명령을 통한 USB 기능의 빈번한 바인딩/언바인딩을 유도하여 레이스 컨디션 트리거
🛡️ 대응 방법
dwc3 드라이버의 레이스 컨디션 수정 패치가 적용된 최신 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이상인지 확인