🇰🇷 한글 설명
Linux 커널의 cirrus-qemu 드라이버가 PCI probe 과정에서 BAR0 크기를 검증하지 않아 발생하는 취약점입니다. BAR0 크기가 예상되는 VRAM 크기(4MB)보다 작을 경우, 프레임버퍼 업데이트 시 할당된 메모리 범위를 초과하여 쓰기를 시도함으로써 커널 페이지 폴트(Page Fault)를 유발합니다.
💡 쉬운 설명
그래픽 드라이버가 실제 사용할 수 있는 메모리 크기를 제대로 확인하지 않아, 정해진 범위를 넘어서는 데이터를 쓰려고 할 때 시스템이 충돌하는 문제입니다. 이로 인해 시스템이 멈추거나 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
drm/cirrus-qemu: Validate BAR0 size during probe
The `cirrus-qemu` driver relies on `CIRRUS_VRAM_SIZE` (4 MB) to validate
framebuffer sizes. However, during PCI probe, the driver mapped BAR0
without verifying that its size matches `CIRRUS_VRAM_SIZE`.
If a PCI device with a BAR0 smaller than 4 MB is bound to the driver, the
mapped VRAM will be smaller than expected. Because validation checks assume
4 MB VRAM, framebuffers larger than the mapped memory can be created.
When the display plane is updated (e.g. during release),
`cirrus_primary_plane_helper_atomic_update()` copies the framebuffer to
VRAM using `drm_fb_memcpy()`. Writing past the end of the mapped I/O memory
causes a supervisor write page fault:
BUG: unable to handle page fault for address: ffffc9000389c000
...
RIP: 0010:memcpy_toio+0x7c/0xe0 arch/x86/lib/iomem.c:110
...
Call Trace:
<TASK>
iosys_map_memcpy_to include/linux/iosys-map.h:285 [inline]
drm_fb_memcpy+0x325/0x5d0 drivers/gpu/drm/drm_format_helper.c:442
cirrus_primary_plane_helper_atomic_update+0x98a/0xb00
drivers/gpu/drm/tiny/cirrus-qemu.c:358
drm_atomic_helper_commit_planes+0x626/0xea0
drivers/gpu/drm/drm_atomic_helper.c:3038
drm_atomic_helper_commit_tail+0x60/0x510
drivers/gpu/drm/drm_atomic_helper.c:1989
commit_tail+0x2b1/0x3c0 drivers/gpu/drm/drm_atomic_helper.c:2074
drm_atomic_helper_commit+0xa77/0xb10
drivers/gpu/drm/drm_atomic_helper.c:2312
Fix this by validating in `cirrus_pci_probe()` that the PCI BAR0 resource
is not less than `CIRRUS_VRAM_SIZE`, returning `-ENODEV` if it is less.
📍 영향받는 시스템
Linux kernel (cirrus-qemu driver 사용 환경)
⚔️ 공격 벡터
BAR0 크기가 4MB보다 작은 PCI 장치를 연결하여 드라이버를 로드한 후, 프레임버퍼 업데이트를 유도하여 커널 패닉 유발
🛡️ 대응 방법
cirrus_pci_probe() 함수에서 PCI BAR0 리소스 크기가 CIRRUS_VRAM_SIZE보다 작은지 검증하고, 작을 경우 -ENODEV를 반환하도록 커널 패치 적용
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 수정된 패치 버전인지 확인합니다.