🇰🇷 한글 설명
Linux 커널의 AMD IOMMU 구현에서 iommu_completion_wait() 함수가 명령 완료를 기다리지 않고 조기에 반환하는 논리적 레이스 컨디션 취약점이 발견되었습니다. 이로 인해 특정 상황에서 IOMMU가 이전 명령을 처리하는 동안 페이지 테이블 페이지가 해제되어 Use-After-Free(UAF) 상태가 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터의 하드웨어가 명령을 다 끝낼 때까지 기다려야 하는데, 너무 빨리 '다 끝났다'고 착각하고 다음 작업을 진행하는 문제입니다. 이 과정에서 이미 사용 중인 메모리를 지워버려 시스템 오류나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
iommu/amd: Wait for completion instead of returning early in iommu_completion_wait()
need_sync is a per-IOMMU flag shared by all domains and devices behind
that IOMMU. It is set whenever a command is queued with sync == true and
cleared when a completion-wait (CWAIT) command is queued. However, a
cleared need_sync only means that a covering CWAIT has been queued, not
that all previously queued commands have actually completed in hardware.
iommu_completion_wait() read need_sync locklessly and returned early
when it was false. This breaks the "block until all previously queued
commands have completed" contract in a multi-CPU scenario:
CPU2: queue inv-B => need_sync = true
CPU1: queue CWAIT(N); need_sync = false; then wait_on_sem(N)
CPU2: read need_sync == false => return 0 (no wait!)
CPU2 returns without waiting for any sequence number even though its
inv-B may not have completed yet (CWAIT(N), queued after inv-B, has not
been signaled). CPU2 then proceeds to, for example, free page-table
pages while the IOMMU can still walk stale translations, opening a
use-after-free window. This is a logical race in the meaning of the
flag, not a memory-visibility issue, so barriers alone do not help.
Fix it without losing the optimization of avoiding redundant CWAIT
commands: take iommu->lock before testing need_sync, and when it is
false do not return early but wait for the last allocated sequence
number (cmd_sem_val). Since need_sync == false implies no sync command
was queued after the last CWAIT, that CWAIT is FIFO-ordered after every
not-yet-completed command, so waiting for its sequence number guarantees
all prior commands (possibly queued by another CPU) have completed. The
common path with pending work is unchanged and no extra hardware command
is issued.
📍 영향받는 시스템
AMD IOMMU를 사용하는 Linux 커널 (패치 적용 전 버전)
⚔️ 공격 벡터
멀티 CPU 환경에서 특정 I/O 명령과 동기화 명령이 동시에 실행될 때 발생하는 논리적 레이스 컨디션 유도
🛡️ 대응 방법
AMD IOMMU 관련 커널 패치를 적용하여 iommu_completion_wait() 함수가 명령 완료를 보장하도록 업데이트
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 최신 보안 패치 버전인지 확인
📊 CVSS Vector String
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
💻 영향받는 소프트웨어
NVIDIA vGPU Guest Driver for Linux