🇰🇷 한글 설명
Linux 커널의 writeback 과정에서 특정 선점 모드(PREEMPT_LAZY) 사용 시 RCU 정지 상태를 보고하지 않아 발생하는 문제입니다. 이로 인해 BPF나 ftrace 작업이 RCU grace period를 기다리는 동안 시스템이 멈추거나 커널 패닉이 발생할 수 있습니다.
💡 쉬운 설명
리눅스 시스템이 특정 작업을 처리하는 동안 시스템의 다른 중요한 작업들이 응답하지 못하고 멈춰버리는 현상이 발생할 수 있습니다. 이 문제가 해결되지 않으면 시스템이 갑자기 꺼지거나 완전히 먹통이 될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
writeback: report a Tasks-RCU quiescent state per cgwb drain pass
cleanup_offline_cgwbs_workfn() drains a dying cgwb by calling
cleanup_offline_cgwb() until it returns false, with a cond_resched()
between passes. On a CONFIG_PREEMPTION kernel that cond_resched() does
nothing: _cond_resched() is a plain "return 0", and under PREEMPT_DYNAMIC
the full and lazy modes disable it. Since commit 7dadeaa6e851 ("sched:
Further restrict the preemption modes") those are the only two models on
the architectures with PREEMPT_LAZY support, arm64 and x86 among them, so
the drain loop never reports a Tasks-RCU quiescent state.
A worker draining a cgwb with millions of attached inodes runs for
minutes. On a 6.18 arm64 host in lazy mode the cgwb worker drained one
dying cgroup's writeback domain for over 11 minutes. A BPF program unlink
(bpf_trampoline_unlink_prog -> bpf_trampoline_update ->
unregister_ftrace_direct -> ftrace_shutdown -> synchronize_rcu_tasks())
waited on that grace period while holding the trampoline mutex, 42 tasks
queued behind it in D state, and the hung task detector fired at 614 s and
panicked the host. Any BPF or ftrace detach during a long drain inherits
the drain's length.
Fix this by calling cond_resched_tasks_rcu_qs() so we do not stall out
anybody who calls sycnrhonize_rcu_tasks(). We put this in a do { } while
loop because if we have many small cgroups cleanup_offline_cgwb() will
return false and we will never call cond_resched_tasks_rcu_qs(), creating
the same problem.
📍 영향받는 시스템
Linux kernel (특히 arm64 및 x86 아키텍처에서 PREEMPT_LAZY/DYNAMIC 모드 사용 시)
⚔️ 공격 벡터
직접적인 공격보다는 대량의 inode를 가진 cgroup을 정리하는 과정에서 시스템 자원 고갈 및 커널 패닉을 유도하는 방식
🛡️ 대응 방법
커널 패치(cond_resched_tasks_rcu_qs() 호출 추가)를 적용하여 최신 커널 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인