🇰🇷 한글 설명
Linux 커널의 comedi 드라이버에서 폴링(polling) 작업과 장치 분리(detaching) 작업 간의 경쟁 상태로 인해 Use-After-Free 취약점이 발생합니다. 장치가 분리될 때 대기 큐에 활성 작업이 남아 있음에도 메모리가 해제되어 시스템 불안정이나 권한 상승을 초래할 수 있습니다.
💡 쉬운 설명
장치를 컴퓨터에서 제거하는 과정과 장치를 사용 중인 프로그램이 충돌하여, 이미 사라진 메모리 영역에 접근하려고 할 때 발생하는 오류입니다. 이로 인해 시스템이 멈추거나 해커가 시스템 제어권을 얻을 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
comedi: fix race between polling and detaching
syzbot reports a use-after-free in comedi in the below link, which is
due to comedi gladly removing the allocated async area even though poll
requests are still active on the wait_queue_head inside of it. This can
cause a use-after-free when the poll entries are later triggered or
removed, as the memory for the wait_queue_head has been freed. We need
to check there are no tasks queued on any of the subdevices' wait queues
before allowing the device to be detached by the `COMEDI_DEVCONFIG`
ioctl.
Tasks will read-lock `dev->attach_lock` before adding themselves to the
subdevice wait queue, so fix the problem in the `COMEDI_DEVCONFIG` ioctl
handler by write-locking `dev->attach_lock` before checking that all of
the subdevices are safe to be deleted. This includes testing for any
sleepers on the subdevices' wait queues. It remains locked until the
device has been detached. This requires the `comedi_device_detach()`
function to be refactored slightly, moving the bulk of it into new
function `comedi_device_detach_locked()`.
Note that the refactor of `comedi_device_detach()` results in
`comedi_device_cancel_all()` now being called while `dev->attach_lock`
is write-locked, which wasn't the case previously, but that does not
matter.
Thanks to Jens Axboe for diagnosing the problem and co-developing this
patch.
📍 영향받는 시스템
comedi 드라이버를 사용하는 Linux 커널 버전
⚔️ 공격 벡터
로컬 사용자가 COMEDI_DEVCONFIG ioctl 호출을 통해 특정 타이밍에 장치 분리를 유도하여 메모리 오류 유발
🛡️ 대응 방법
comedi 드라이버의 race condition을 해결한 최신 Linux 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 패치된 최신 보안 업데이트 버전인지 확인합니다.