🇰🇷 한글 설명
리눅스 커널의 staging 드라이버 fbtft에서 dirty_lock 잠금이 IRQ에 안전하지 않아 발생하는 잠금 역전(lock inversion) 문제입니다. fbtft_mkdirty()는 하드웨어 인터럽트 컨텍스트에서 호출될 수 있는 반면, fbtft_deferred_io()는 인터럽트가 활성화된 워크큐에서 같은 잠금을 획득하여 교착 상태가 발생할 수 있습니다. 수정은 spin_lock_irqsave()와 spin_lock_irq()를 사용하는 것입니다.
💡 쉬운 설명
화면에 그림을 그리는 장치 드라이버에서 두 작업이 같은 잠금을 서로 다른 방식으로 기다리다 시스템이 멈출 수 있는 문제입니다. 잠금을 올바르게 사용하도록 고쳐 교착 상태를 막습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
staging: fbtft: make dirty_lock IRQ-safe
fbtft_mkdirty() can be reached from the fbcon rendering path while
processing printk() in hardirq context. Meanwhile, dirty_lock is also
taken by fbtft_deferred_io() in workqueue context with local interrupts
enabled.
Lockdep reports a possible IRQ lock inversion involving dirty_lock and
console_owner. A hardirq can interrupt a CPU holding dirty_lock and
enter the console rendering path, which can attempt to acquire
dirty_lock again.
The following lockdep report was observed on an RK3566 system with
CONFIG_PROVE_LOCKING enabled:
WARNING: possible irq lock inversion dependency detected
swapper/2/0 just changed the state of lock:
(console_owner){-...}-{0:0}
but this lock took another, HARDIRQ-unsafe lock in the past:
(&par->dirty_lock){+.+.}-{2:2}
CPU0 CPU1
---- ----
lock(&par->dirty_lock);
local_irq_disable();
lock(console_owner);
lock(&par->dirty_lock);
<Interrupt>
lock(console_owner);
*** DEADLOCK ***
Use spin_lock_irqsave() for fbtft_mkdirty() and spin_lock_irq() for
fbtft_deferred_io(). They only access the dirty line range, so the
IRQ-off regions remain short.
📍 영향받는 시스템
fbtft 드라이버를 포함한 수정 이전의 Linux 커널 (staging 드라이버 사용 시, 예: RK3566 등 SPI 디스플레이 구성)
⚔️ 공격 벡터
로컬 사용자가 콘솔 출력이나 fbcon 렌더링을 유발하여 교착 상태를 일으키는 방식으로 서비스 거부(DoS)를 시도할 수 있음
🛡️ 대응 방법
패치가 포함된 최신 리눅스 커널로 업데이트하거나, fbtft 드라이버를 사용하지 않는다면 해당 모듈을 비활성화
🔧 검증 코드
커널 버전을 확인하고, fbtft_mkdirty 관련 코드에 spin_lock_irqsave가 적용되어 있으면 패치가 반영된 것이며, 출력이 없거나 드라이버가 없으면 해당 환경에 영향이 없는 것입니다.
uname -r && (grep -rn 'spin_lock_irqsave' drivers/staging/fbtft/fbtft-core.c 2>/dev/null | grep -i dirty)