🇰🇷 한글 설명
Linux 커널 xhci_disable_slot() 함수에서 xhci_alloc_command()로 할당한 completion 구조체가 에러 경로에서 제대로 해제되지 않아 메모리 누수 발생. kfree() 대신 xhci_free_command()을 사용하면 command와 completion 구조체를 모두 올바르게 해제할 수 있음.
💡 쉬운 설명
USB 장치 관리 코드에서 메모리를 할당했지만 오류 시 완전히 해제하지 않는 버그입니다. 올바른 해제 함수를 사용하면 간단하게 고칠 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
usb: xhci: Fix memory leak in xhci_disable_slot()
xhci_alloc_command() allocates a command structure and, when the
second argument is true, also allocates a completion structure.
Currently, the error handling path in xhci_disable_slot() only frees
the command structure using kfree(), causing the completion structure
to leak.
Use xhci_free_command() instead of kfree(). xhci_free_command() correctly
frees both the command structure and the associated completion structure.
Since the command structure is allocated with zero-initialization,
command->in_ctx is NULL and will not be erroneously freed by
xhci_free_command().
This bug was found using an experimental static analysis tool we are
developing. The tool is based on the LLVM framework and is specifically
designed to detect memory management issues. It is currently under
active development and not yet publicly available, but we plan to
open-source it after our research is published.
The bug was originally detected on v6.13-rc1 using our static analysis
tool, and we have verified that the issue persists in the latest mainline
kernel.
We performed build testing on x86_64 with allyesconfig using GCC=11.4.0.
Since triggering these error paths in xhci_disable_slot() requires specific
hardware conditions or abnormal state, we were unable to construct a test
case to reliably trigger these specific error paths at runtime.
📍 영향받는 시스템
Linux kernel v6.13-rc1 이후 최신 mainline kernel (특히 xhci 드라이버 사용 시스템)
⚔️ 공격 벡터
xhci_disable_slot() 에러 경로 트리거를 위한 특정 하드웨어 조건 또는 비정상 상태 필요
🛡️ 대응 방법
Linux kernel 최신 버전으로 업데이트하여 xhci 메모리 누수 패치 적용
🔧 검증 코드
커널 버전이 v6.13 이상이면 패치된 버전으로 업데이트하고, 그 이하면 보안 업데이트 확인 필요
uname -r | grep -E 'v6\.(13|1[4-9]|[2-9])' && echo '업데이트 필요' || echo '확인 필요'