🇰🇷 한글 설명
Linux 커널의 hackrf 드라이버에서 hackrf_probe() 함수가 장치를 등록한 후 오류 발생 시 메모리를 직접 해제하여 발생하는 레이스 컨디션 취약점입니다. 이로 인해 이미 열려 있는 파일 디스크립터가 해제된 메모리에 접근하는 Use-After-Free(UAF) 및 Double-Free 취약점이 발생할 수 있습니다.
💡 쉬운 설명
장치를 사용하는 도중에 장치 연결이 끊기면, 컴퓨터가 이미 사용 중인 메모리를 실수로 지워버리는 문제가 발생합니다. 이로 인해 시스템이 충돌하거나 해커가 시스템 권한을 탈취할 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
media: hackrf: fix to not free memory after the device is registered in hackrf_probe()
In hackrf driver, the following race condition occurs:
```
CPU0 CPU1
hackrf_probe()
kzalloc(); // alloc hackrf_dev
....
v4l2_device_register();
....
fd = sys_open("/path/to/dev"); // open hackrf fd
....
v4l2_device_unregister();
....
kfree(); // free hackrf_dev
....
sys_ioctl(fd, ...);
v4l2_ioctl();
video_is_registered() // UAF!!
....
sys_close(fd);
v4l2_release() // UAF!!
hackrf_video_release()
kfree(); // DFB!!
```
When a V4L2 or video device is unregistered, the device node is removed so
new open() calls are blocked.
However, file descriptors that are already open-and any in-flight I/O-do
not terminate immediately; they remain valid until the last reference is
dropped and the driver's release() is invoked.
Therefore, freeing device memory on the error path after hackrf_probe()
has registered dev it will lead to a race to use-after-free vuln, since
those already-open handles haven't been released yet.
And since release() free memory too, race to use-after-free and
double-free vuln occur.
To prevent this, if device is registered from probe(), it should be
modified to free memory only through release() rather than calling
kfree() directly.
📍 영향받는 시스템
Linux kernel (hackrf driver 포함 버전)
⚔️ 공격 벡터
장치 등록과 해제 과정 사이의 타이밍을 이용한 레이스 컨디션 공격을 통해 메모리 오류 유도
🛡️ 대응 방법
커널 패치를 통해 probe() 단계에서 장치 등록 성공 시 메모리를 직접 해제하지 않고 release() 함수를 통해서만 해제되도록 수정
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 수정된 최신 패치 버전인지 확인합니다.