🇰🇷 한글 설명
Linux 커널의 성능 이벤트 스케줄링 함수(ctx_sched_in)에서 perf-context 락을 잡은 상태에서 wait-queue 락을 획득하려고 시도할 때 잘못된 대기 컨텍스트 오류가 발생합니다. 이는 고정된(pinned) 성능 이벤트 실패 시 ring buffer 스레드를 깨울 때 발생하며, irq_work를 통해 비동기로 처리함으로써 해결됩니다.
💡 쉬운 설명
Linux 커널의 성능 측정 기능에서 두 개의 잠금장치를 잘못된 순서로 사용하려고 할 때 시스템이 충돌할 수 있는 문제입니다. 이 버그는 특정 상황에서 커널이 교착 상태에 빠지거나 불안정해질 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
perf/core: Fix invalid wait context in ctx_sched_in()
Lockdep found a bug in the event scheduling when a pinned event was
failed and wakes up the threads in the ring buffer like below.
It seems it should not grab a wait-queue lock under perf-context lock.
Let's do it with irq_work.
[ 39.913691] =============================
[ 39.914157] [ BUG: Invalid wait context ]
[ 39.914623] 6.15.0-next-20250530-next-2025053 #1 Not tainted
[ 39.915271] -----------------------------
[ 39.915731] repro/837 is trying to lock:
[ 39.916191] ffff88801acfabd8 (&event->waitq){....}-{3:3}, at: __wake_up+0x26/0x60
[ 39.917182] other info that might help us debug this:
[ 39.917761] context-{5:5}
[ 39.918079] 4 locks held by repro/837:
[ 39.918530] #0: ffffffff8725cd00 (rcu_read_lock){....}-{1:3}, at: __perf_event_task_sched_in+0xd1/0xbc0
[ 39.919612] #1: ffff88806ca3c6f8 (&cpuctx_lock){....}-{2:2}, at: __perf_event_task_sched_in+0x1a7/0xbc0
[ 39.920748] #2: ffff88800d91fc18 (&ctx->lock){....}-{2:2}, at: __perf_event_task_sched_in+0x1f9/0xbc0
[ 39.921819] #3: ffffffff8725cd00 (rcu_read_lock){....}-{1:3}, at: perf_event_wakeup+0x6c/0x470
📍 영향받는 시스템
Linux 커널 6.15.0-next 및 이전 버전(next-20250530 이전)
⚔️ 공격 벡터
로컬 사용자가 특정 perf 이벤트를 반복적으로 트리거하여 커널 패닉 또는 서비스 거부 유발
🛡️ 대응 방법
Linux 커널을 최신 버전으로 업데이트하여 ctx_sched_in() 함수의 irq_work 기반 수정사항 적용
🔧 검증 코드
커널 버전이 영향받는 버전과 일치하면 패치 필요. 최신 버전(next-20250530 이후)이면 안전함
uname -r | grep -E 'next-2025053|6\.15'