🇰🇷 한글 설명
Linux 커널의 rainshadow-cec 드라이버 인터럽트 핸들러에서 스핀락 획득 전에 버퍼 크기를 검사하는 TOCTOU 레이스 컨디션 취약점입니다. 여러 인터럽트가 동시에 접근하면서 버퍼 오버플로우가 발생할 수 있습니다.
💡 쉬운 설명
Linux 커널의 CEC 드라이버에서 두 개의 인터럽트가 동시에 같은 메모리에 접근할 때 발생하는 동기화 문제입니다. 메모리 손상과 시스템 불안정을 초래할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
media: rainshadow-cec: fix TOCTOU race condition in rain_interrupt()
In the interrupt handler rain_interrupt(), the buffer full check on
rain->buf_len is performed before acquiring rain->buf_lock. This
creates a Time-of-Check to Time-of-Use (TOCTOU) race condition, as
rain->buf_len is concurrently accessed and modified in the work
handler rain_irq_work_handler() under the same lock.
Multiple interrupt invocations can race, with each reading buf_len
before it becomes full and then proceeding. This can lead to both
interrupts attempting to write to the buffer, incrementing buf_len
beyond its capacity (DATA_SIZE) and causing a buffer overflow.
Fix this bug by moving the spin_lock() to before the buffer full
check. This ensures that the check and the subsequent buffer modification
are performed atomically, preventing the race condition. An corresponding
spin_unlock() is added to the overflow path to correctly release the
lock.
This possible bug was found by an experimental static analysis tool
developed by our team.
📍 영향받는 시스템
Linux kernel rainshadow-cec driver - TOCTOU 패치 적용 전 모든 버전
⚔️ 공격 벡터
로컬 공격자가 CEC 인터페이스를 통해 정확한 타이밍으로 인터럽트를 발생시켜 버퍼 오버플로우 유발
🛡️ 대응 방법
Linux 커널을 최신 버전으로 업데이트하여 spin_lock() 위치를 버퍼 검사 전으로 이동한 패치 적용
🔧 검증 코드
spin_lock이 버퍼 검사 전에 위치하는지 확인하거나, 커널 버전을 확인하여 패치된 버전으로 업데이트되었는지 검증합니다.
grep 'spin_lock' /lib/modules/$(uname -r)/build/drivers/media/rc/rainshadow-cec.c 2>/dev/null && echo 'Patched' || uname -r