🇰🇷 한글 설명
리눅스 커널의 timer_shutdown_sync() 함수에서 타이머 종료와 만료 작업 간의 레이스 컨디션(경쟁 상태)이 발생합니다. 타이머가 실행 중인 상태에서 함수 포인터가 NULL로 설정되어 expire_timers() 호출 시 WARN_ON 경고가 발생할 수 있습니다.
💡 쉬운 설명
타이머를 끄는 과정에서 타이머가 아직 작동 중인데 실행할 명령어를 먼저 지워버려 발생하는 오류입니다. 이로 인해 시스템이 예상치 못한 상태에 빠져 경고 메시지를 출력할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
timers: Fix NULL function pointer race in timer_shutdown_sync()
There is a race condition between timer_shutdown_sync() and timer
expiration that can lead to hitting a WARN_ON in expire_timers().
The issue occurs when timer_shutdown_sync() clears the timer function
to NULL while the timer is still running on another CPU. The race
scenario looks like this:
CPU0 CPU1
<SOFTIRQ>
lock_timer_base()
expire_timers()
base->running_timer = timer;
unlock_timer_base()
[call_timer_fn enter]
mod_timer()
...
timer_shutdown_sync()
lock_timer_base()
// For now, will not detach the timer but only clear its function to NULL
if (base->running_timer != timer)
ret = detach_if_pending(timer, base, true);
if (shutdown)
timer->function = NULL;
unlock_timer_base()
[call_timer_fn exit]
lock_timer_base()
base->running_timer = NULL;
unlock_timer_base()
...
// Now timer is pending while its function set to NULL.
// next timer trigger
<SOFTIRQ>
expire_timers()
WARN_ON_ONCE(!fn) // hit
...
lock_timer_base()
// Now timer will detach
if (base->running_timer != timer)
ret = detach_if_pending(timer, base, true);
if (shutdown)
timer->function = NULL;
unlock_timer_base()
The problem is that timer_shutdown_sync() clears the timer function
regardless of whether the timer is currently running. This can leave a
pending timer with a NULL function pointer, which triggers the
WARN_ON_ONCE(!fn) check in expire_timers().
Fix this by only clearing the timer function when actually detaching the
timer. If the timer is running, leave the function pointer intact, which is
safe because the timer will be properly detached when it finishes running.
📍 영향받는 시스템
Linux Kernel (timer_shutdown_sync() 함수 관련 버전)
⚔️ 공격 벡터
로컬 시스템에서 특정 타이머 종료 시나리오를 유도하여 레이스 컨디션 발생 (Local)
🛡️ 대응 방법
타이머가 실제로 분리(detach)될 때만 함수 포인터를 NULL로 설정하도록 커널 패치 적용
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인합니다.