🇰🇷 한글 설명
Linux 커널의 dma-mapping에서 pfn_valid() 함수가 MMIO 주소를 실제 RAM으로 오인하여 dma_map_resource()가 오류를 반환하는 취약점입니다. ARM64 SPARSEMEM 환경에서 특정 MMIO 영역이 RAM과 동일한 섹션에 위치할 경우 발생하며, 이를 해결하기 위해 검증 로직을 디버그 코드로 이동하고 PageReserved 체크를 추가했습니다.
💡 쉬운 설명
컴퓨터가 하드웨어 장치와 통신할 때 사용하는 주소를 실제 메모리(RAM)로 착각하여 통신 오류가 발생하는 문제입니다. 이로 인해 라즈베리 파이 4와 같은 특정 기기에서 장치 인식에 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
dma-mapping: move dma_map_resource() sanity check into debug code
dma_map_resource() uses pfn_valid() to ensure the range is not RAM.
However, pfn_valid() only checks for availability of the memory map for
a PFN but it does not ensure that the PFN is actually backed by RAM. On
ARM64 with SPARSEMEM (128MB section granularity), MMIO addresses that
share a section with RAM will falsely trigger the WARN_ON_ONCE and cause
dma_map_resource() to return DMA_MAPPING_ERROR.
This causes a WARNING on Raspberry Pi 4 during spi_bcm2835 probe because
the SPI FIFO register (0xfe204004) falls in the same sparsemem section
as the end of RAM (0xf8000000-0xfbffffff), both in section 31
(0xf8000000-0xffffffff).
Move the sanity check from dma_map_resource() into debug_dma_map_phys()
and replace the unreliable pfn_valid() with pfn_valid() &&
!PageReserved(), which correctly identifies actual usable RAM without
false positives for MMIO regions that happen to have struct pages.
Since dma_map_resource() is dma_map_phys(DMA_ATTR_MMIO), the check
applies equally to both APIs. Any non-reserved page represents kernel
memory to a sufficient degree that using DMA_ATTR_MMIO on it is almost
certainly wrong and risks breaking coherency on non-coherent platforms.
ZONE_DEVICE pages used for PCI P2P DMA (MEMORY_DEVICE_PCI_P2PDMA) have
PageReserved set, so they will not trigger a false positive.
The check no longer blocks the mapping and uses err_printk() to
integrate with dma-debug filtering.
📍 영향받는 시스템
ARM64 아키텍처 기반의 SPARSEMEM을 사용하는 Linux 커널 (예: Raspberry Pi 4)
⚔️ 공격 벡터
직접적인 공격보다는 시스템의 하드웨어 드라이버 로딩 실패 및 서비스 가용성 저하를 유발할 수 있음
🛡️ 대응 방법
해당 패치가 적용된 최신 Linux 커널 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인