🇰🇷 한글 설명
Linux 커널의 usb: gadget: udc 구성 요소에서 gadget_match_driver 함수 호출 시 Use-After-Free(UAF) 취약점이 발생합니다. usb_del_gadget()이 udc 메모리를 해제하는 동안 gadget_match_driver()가 해당 메모리에 동시에 접근하여 NULL 포인터 역참조 및 시스템 충돌을 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터의 USB 관리 장치가 사용 중인데, 시스템이 이를 갑자기 삭제하려고 시도하면서 충돌이 발생하는 문제입니다. 이 과정에서 메모리 관리 오류가 생겨 컴퓨터 시스템이 멈추거나 오류가 날 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: udc: Fix use-after-free in gadget_match_driver
The udc structure acts as the management structure for the gadget,
but their lifecycles are decoupled. A race condition exists where
usb_del_gadget() frees the udc memory (e.g., via mode-switch work)
while gadget_match_driver() concurrently accesses the freed udc memory
(e.g., via configfs), causing a Use-After-Free (UAF) that triggers a
NULL pointer dereference when the freed memory is zeroed:
[39430.908615][ T1171] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[39430.911397][ T1171] pc : __pi_strcmp+0x20/0x140
[39430.911441][ T1171] lr : gadget_match_driver+0x34/0x60
...
[39430.911890][ T1171] usb_gadget_register_driver_owner+0x50/0xf8
[39430.911910][ T1171] gadget_dev_desc_UDC_store+0xf4/0x140
[39430.931308][ T1171] configfs_write_iter+0xec/0x134
[39430.957058][ T1171] Workqueue: events_freezable __dwc3_set_mode
[39430.957287][ T1171] dwc3_gadget_exit+0x34/0x8c
[39430.957304][ T1171] __dwc3_set_mode+0xc0/0x664
Fix this by ensuring the udc structure remains allocated until the
gadget is released. To achieve this, introduce a new
usb_gadget_release() routine to the core. When the gadget is added,
usb_add_gadget() stores the gadget's release routine in the udc
structure and takes a reference to the udc. When the gadget is
released, usb_gadget_release() drops the reference to the udc and
then calls the gadget's release routine.
📍 영향받는 시스템
Linux Kernel (usb gadget driver 관련 구성 요소)
⚔️ 공격 벡터
ConfigFS를 통한 gadget 드라이버 매칭 과정에서의 레이스 컨디션 유도
🛡️ 대응 방법
커널 패치를 통해 usb_gadget_release() 루틴을 도입하여 udc 구조체의 참조 카운트를 관리하도록 업데이트
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 수정된 패치 버전인지 확인합니다.