🇰🇷 한글 설명
Linux 커널의 Xilinx SPI 드라이버에서 FIFO 크기를 잘못 계산하여 발생하는 취약점입니다. 드라이버가 FIFO 크기에 시프트 레지스터를 포함한 잘못된 값을 사용하여 RX FIFO 용량을 초과하는 데이터를 처리하려 할 때, 무한 루프에 빠져 드라이버가 잠기는 현상이 발생합니다.
💡 쉬운 설명
장치의 데이터 저장 공간 크기를 실제보다 하나 더 크게 잘못 인식하는 문제입니다. 이로 인해 데이터가 넘치게 되면 시스템이 다음 단계를 기다리며 무한히 멈춰버리는 현상이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
spi: xilinx: use FIFO occupancy register to determine buffer size
The method the driver uses to determine the size of the FIFO has a
problem. What it currently does is this:
It stops the SPI hardware and writes to the TX FIFO register until TX
FIFO FULL asserts in the status register. But the hardware does not only
have the FIFO, it also has a shift register which can hold a byte. This
can be seen, when writing a byte to the FIFO (while the SPI hardware is
stopped,) the TX FIFO EMPTY is still empty. So, if we have a FIFO size
of 16 for example, the current method returns a 17.
This is a problem, at least when using the driver in irq mode. The same
size determined for the TX FIFO is also assumed for the RX FIFO. When a
SPI transaction wants to write the amount of the FIFO size or more
bytes, the following happens, for example with 16 bytes FIFO size:
The driver stops the SPI hardware and writes 17 bytes to the TX FIFO and
starts the SPI hardware and goes sleep.
The hardware then shifts out 17 bytes (FIFO + shift register) and
simultaneously reads bytes into the RX FIFO, but it only has 16 places,
so it looses one byte. Then TX FIFO empty asserts, wakes the driver
again, which has a fast path and reads 16 bytes from the RX FIFO, but
before reading the last 17th byte (which is lost) it does this:
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
if (!(sr & XSPI_SR_RX_EMPTY_MASK)) {
xilinx_spi_rx(xspi);
rx_words--;
}
It reads the status register and checks if the RX FIFO is not empty.
But it is empty in our case. So this check spins in a while loop
forever locking the driver.
This patch fixes the logic to determine the FIFO size.
📍 영향받는 시스템
Xilinx SPI 드라이버를 사용하는 Linux 커널 기반 시스템
⚔️ 공격 벡터
SPI 통신 시 FIFO 용량을 초과하는 데이터 전송을 유도하여 드라이버를 무한 루프 상태로 만듦
🛡️ 대응 방법
FIFO 크기 계산 로직이 수정된 최신 Linux 커널 패치를 적용하십시오.
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 수정된 패치 버전인지 확인합니다.