🇰🇷 한글 설명
PREEMPT_RT 커널 환경에서 kcov의 임시 저장소가 per-CPU 영역에 할당되어 있어, 중첩된 softirq 발생 시 데이터가 덮어씌워지는 레이스 컨디션 및 데이터 손상 취약점이 존재합니다. 이로 인해 KCOV 상태가 파괴되거나 커널 크래시 및 메모리 누수가 발생할 수 있습니다.
💡 쉬운 설명
리눅스 커널의 특정 기능이 여러 작업이 동시에 몰릴 때 데이터를 제대로 보호하지 못해 시스템이 멈추거나 오류가 생길 수 있는 문제입니다. 작업 저장 공간을 CPU 기준이 아닌 개별 작업 기준으로 변경하여 이 문제를 해결했습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
kcov: fix data corruption and race conditions on PREEMPT_RT
syzbot is reporting KCOV state corruption on PREEMPT_RT kernels, for the
temporary storage used for saving/restoring remote KCOV state is currently
allocated as the per-CPU area.
On PREEMPT_RT kernels, softirq handlers run as preemptible task threads
(e.g., ksoftirqd). If a softirq context preempts a task running a remote
KCOV session, it safely saves the task's state into the per-CPU area.
However, if that softirq thread is subsequently preempted by a higher-
priority softirq thread on the same CPU, the second softirq will overwrite
the same per-CPU area, permanently destroying the original task's KCOV
state.
Fix this data corruption by moving the temporary storage from the per-CPU
area to the per-thread area. Since each softirq thread now owns its own
task context, nested softirq preemption no longer causes data overwrites.
Note that while the temporary storage is now on a per-thread basis, the
per-CPU kcov_percpu_data.lock must be retained, for we need to ensure that
kcov_remote_start() and kcov_remote_stop() operate atomically without
racing against asynchronous interrupts that manipulate the current task's
KCOV state.
It is likely that GFP_KERNEL allocation by vmalloc_node() in kcov_init()
has already called panic() before returning NULL, for there will be no
OOM-killable userspace processes when __init function of built-in module
runs. But this patch also fixes crashing the kernel when vmalloc_node()
in kcov_init() returned NULL, for kcov_init() left per-CPU irq_area == NULL
but kcov_remote_start() depends on per-CPU irq_area != NULL, resulting in
(1) doing vmalloc() in kcov_remote_start() despite !in_task() context
(2) out-of-array-bounds access if (1) succeeded but
kcov->remote_size < CONFIG_KCOV_IRQ_AREA_SIZE
(3) always leak memory allocated by (1), eventually killing all
OOM-killable userspace processes
problems.
📍 영향받는 시스템
PREEMPT_RT 패치가 적용된 Linux Kernel
⚔️ 공격 벡터
로컬 공격자가 특정 타이밍에 softirq를 유발하여 커널 데이터 손상 또는 메모리 누수 유도
🛡️ 대응 방법
kcov 임시 저장소를 per-CPU 영역에서 per-thread 영역으로 변경하는 커널 패치 적용
🔧 검증 코드
출력 결과에 PREEMPT_RT가 포함되어 있는지 확인하여 해당 커널 환경인지 판단합니다.
uname -a | grep -i 'PREEMPT_RT'