🇰🇷 한글 설명
Linux 커널의 rockchip-sfc SPI 드라이버에서 remove() 콜백 함수가 이중 해제(double-free) 취약점을 발생시킵니다. devm_spi_register_controller()는 자동으로 정리될 때 unregister를 호출하는데, 코드에서 수동으로 spi_unregister_controller()를 또 호출하여 같은 리소스를 두 번 해제하게 됩니다.
💡 쉬운 설명
Linux 드라이버가 메모리 정리를 자동으로 하도록 설정했음에도 수동으로 두 번 정리하려고 해서 시스템이 충돌합니다. 장치를 제거할 때 커널이 정리 작업을 두 번 수행하려다 보니 메모리 손상이 발생합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
spi: rockchip-sfc: Fix double-free in remove() callback
The driver uses devm_spi_register_controller() for registration, which
automatically unregisters the controller via devm cleanup when the
device is removed. The manual call to spi_unregister_controller() in
the remove() callback can lead to a double-free.
And to make sure controller is unregistered before DMA buffer is
unmapped, switch to use spi_register_controller() in probe().
📍 영향받는 시스템
Linux kernel rockchip-sfc SPI 드라이버 (영향받는 정확한 커널 버전은 패치 적용 전 모든 버전)
⚔️ 공격 벡터
물리적 SPI 장치 제거/삽입 또는 드라이버 언로드 시 remove() 콜백 트리거로 인한 커널 패닉 또는 메모리 손상
🛡️ 대응 방법
Linux 커널 패치 적용: spi_register_controller() 사용으로 변경하고 remove() 콜백에서 중복된 spi_unregister_controller() 호출 제거
🔧 검증 코드
결과에 'Vulnerable'이 나타나면 해당 커널 버전이 취약점을 포함하고 있으며, 커널 업그레이드 또는 백포트 패치가 필요합니다.
grep -r 'devm_spi_register_controller' /lib/modules/$(uname -r)/kernel/drivers/spi/ 2>/dev/null && echo 'Vulnerable' || echo 'Not found'