🇰🇷 한글 설명
Linux 커널의 ring-buffer에서 발생하는 레이스 컨디션 취약점으로, 버퍼 교체 시 커밋 카운터가 일시적으로 0이 되어 쓰기 작업 중에도 버퍼 스왑이 허용될 수 있습니다. 이로 인해 버퍼 상태의 불일치가 발생하며 커널 경고(RB_WARN_ON)가 트리거됩니다. 이를 해결하기 위해 커밋 카운터 대신 현재 컨텍스트(current_context)를 사용하여 버퍼의 사용 상태를 확인하도록 수정되었습니다.
💡 쉬운 설명
데이터를 기록하는 도중에 시스템이 실수로 기록 중인 공간을 다른 용도로 바꿔버리는 오류가 있습니다. 이로 인해 데이터가 꼬이거나 시스템에 경고 메시지가 나타날 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ring-buffer: Use current_context for safe per-CPU buffer swap
The ring_buffer_swap_cpu() function currently checks the per-CPU
committing counter to determine if a buffer is actively being written to
before performing the swap. However, there exists a race window where
this check can be bypassed:
ring_buffer_lock_reserve
cpu_buffer = buffer->buffers[cpu]; // cpu_buffer_a
rb_reserve_next_event
rb_start_commit // inc committing
if (unlikely(READ_ONCE(cpu_buffer->buffer) != buffer)) {...}
__rb_reserve_next
rb_move_tail
rb_end_commit(cpu_buffer); // dec committing => 0
/* interrupt hits here, successfully swaps! */
local_inc(&cpu_buffer->committing);
ring_buffer_unlock_commit
cpu_buffer = buffer->buffers[cpu]; // cpu_buffer_b
rb_commit
rb_end_commit
RB_WARN_ON(cpu_buffer, !local_read(&cpu_buffer->committing))
// triggers warning
The committing counter can temporarily drop to 0 during a single write
operation (within rb_move_tail), creating a window where swap can
succeed even though the write is still in progress. This leads to
inconsistent buffer state and triggers the RB_WARN_ON in rb_commit().
Replace the committing counter check with current_context checks, which
are set at the entry of ring_buffer_lock_reserve() and remain valid
throughout the entire write operation, providing a reliable indicator of
buffer busy state during swap.
📍 영향받는 시스템
Linux Kernel (ring-buffer 관련 모듈 사용 시스템)
⚔️ 공격 벡터
특정 타이밍에 인터럽트를 발생시켜 버퍼 교체 로직의 레이스 컨디션을 유도하는 방식
🛡️ 대응 방법
커밋 카운터 체크 대신 current_context를 사용하는 최신 Linux 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 패치 버전인지 확인