🇰🇷 한글 설명
Linux 커널의 zram 구성 요소에서 zram_writeback_endio 함수 내 use-after-free 취약점이 발견되었습니다. bio 완료 핸들러와 writeback 작업 간의 레이스 컨디션으로 인해 NULL 포인터 역참조 및 시스템 충돌이 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터 메모리를 관리하는 과정에서 두 가지 작업이 동시에 충돌하여, 이미 삭제된 메모리 영역을 다시 사용하려다 시스템이 멈추는 문제입니다. 이로 인해 시스템이 갑자기 꺼지거나 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
zram: fix use-after-free in zram_writeback_endio
A crash was observed in zram_writeback_endio due to a NULL pointer
dereference in wake_up. The root cause is a race condition between the
bio completion handler (zram_writeback_endio) and the writeback task.
In zram_writeback_endio, wake_up() is called on &wb_ctl->done_wait after
releasing wb_ctl->done_lock. This creates a race window where the
writeback task can see num_inflight become 0, return, and free wb_ctl
before zram_writeback_endio calls wake_up().
CPU 0 (zram_writeback_endio) CPU 1 (writeback_store)
============================ ============================
zram_writeback_slots
zram_submit_wb_request
zram_submit_wb_request
wait_event(wb_ctl->done_wait)
spin_lock(&wb_ctl->done_lock);
list_add(&req->entry, &wb_ctl->done_reqs);
spin_unlock(&wb_ctl->done_lock);
wake_up(&wb_ctl->done_wait);
zram_complete_done_reqs
spin_lock(&wb_ctl->done_lock);
list_add(&req->entry, &wb_ctl->done_reqs);
spin_unlock(&wb_ctl->done_lock);
while (num_inflight) > 0)
spin_lock(&wb_ctl->done_lock);
list_del(&req->entry);
spin_unlock(&wb_ctl->done_lock);
// num_inflight becomes 0
atomic_dec(num_inflight);
// Leave zram_writeback_slots
// Free wb_ctl
release_wb_ctl(wb_ctl);
// UAF crash!
wake_up(&wb_ctl->done_wait);
This patch fixes this race by using RCU. By protecting wb_ctl with
rcu_read_lock() in zram_writeback_endio and using kfree_rcu() to free it,
we ensure that wb_ctl remains valid during the execution of
zram_writeback_endio.
📍 영향받는 시스템
Linux kernel (zram module 사용 환경)
⚔️ 공격 벡터
특정 조건에서 zram 쓰기백 작업을 유도하여 레이스 컨디션을 발생시킴으로써 시스템 충돌 유도
🛡️ 대응 방법
RCU(Read-Copy-Update) 메커니즘을 적용하여 수정된 최신 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 패치된 버전인지 배포판 보안 공지를 통해 확인