🇰🇷 한글 설명
Linux 커널의 ftrace 기능에서 발생하는 경합 조건으로, ftrace_dump()가 trace_pipe 읽기와 동시에 호출될 때 trace_printk_seq()의 WARN_ON_ONCE() 검사가 부적절하게 트리거됩니다. ring buffer가 비어있을 때 iter.seq의 크기 검사에서 오류를 발생시키는 문제입니다.
💡 쉬운 설명
Linux 시스템의 추적 기능에서 두 개의 작업이 동시에 실행될 때 메모리 상태 검사가 실패하는 버그입니다. 일반적인 보안 취약점이 아니라 시스템 안정성을 저해하는 커널 문제입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ftrace: Fix potential warning in trace_printk_seq during ftrace_dump
When calling ftrace_dump_one() concurrently with reading trace_pipe,
a WARN_ON_ONCE() in trace_printk_seq() can be triggered due to a race
condition.
The issue occurs because:
CPU0 (ftrace_dump) CPU1 (reader)
echo z > /proc/sysrq-trigger
!trace_empty(&iter)
trace_iterator_reset(&iter) <- len = size = 0
cat /sys/kernel/tracing/trace_pipe
trace_find_next_entry_inc(&iter)
__find_next_entry
ring_buffer_empty_cpu <- all empty
return NULL
trace_printk_seq(&iter.seq)
WARN_ON_ONCE(s->seq.len >= s->seq.size)
In the context between trace_empty() and trace_find_next_entry_inc()
during ftrace_dump, the ring buffer data was consumed by other readers.
This caused trace_find_next_entry_inc to return NULL, failing to populate
`iter.seq`. At this point, due to the prior trace_iterator_reset, both
`iter.seq.len` and `iter.seq.size` were set to 0. Since they are equal,
the WARN_ON_ONCE condition is triggered.
Move the trace_printk_seq() into the if block that checks to make sure the
return value of trace_find_next_entry_inc() is non-NULL in
ftrace_dump_one(), ensuring the 'iter.seq' is properly populated before
subsequent operations.
📍 영향받는 시스템
Linux kernel ftrace 기능 (커널 버전 미지정, 최신 버전 영향)
⚔️ 공격 벡터
sysrq 트리거를 통한 ftrace_dump() 호출과 trace_pipe 동시 접근
🛡️ 대응 방법
Linux 커널을 해당 패치가 적용된 최신 버전으로 업데이트
🔧 검증 코드
커널 버전과 ftrace 기능 활성화 여부를 확인하여 취약점 영향 범위 판단
uname -r && grep CONFIG_FTRACE /boot/config-$(uname -r) 2>/dev/null