🇰🇷 한글 설명
Linux 커널 perf 서브시스템에서 이벤트 초기화가 부분적으로 완료된 상태에서 __free_event() 호출 시 WARN_ON(!ctx)가 발생할 수 있는 문제입니다. child_event->ctx 할당 시점을 앞당겨 정리 루틴의 전제 조건을 만족시키도록 수정되었습니다.
💡 쉬운 설명
리눅스 커널의 성능 모니터링 기능에서 내부 초기화 순서 문제로 경고 메시지가 발생할 수 있었습니다. 이를 해결하기 위해 초기화 순서를 조정하여 오류 처리 경로가 안전하게 동작하도록 고쳤습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
perf/core: Fix WARN_ON(!ctx) in __free_event() for partial init
Move the get_ctx(child_ctx) call and the child_event->ctx assignment to
occur immediately after the child event is allocated. Ensure that
child_event->ctx is non-NULL before any subsequent error path within
inherit_event calls free_event(), satisfying the assumptions of the
cleanup code.
Details:
There's no clear Fixes tag, because this bug is a side-effect of
multiple interacting commits over time (up to 15 years old), not
a single regression.
The code initially incremented refcount then assigned context
immediately after the child_event was created. Later, an early
validity check for child_event was added before the
refcount/assignment. Even later, a WARN_ON_ONCE() cleanup check was
added, assuming event->ctx is valid if the pmu_ctx is valid.
The problem is that the WARN_ON_ONCE() could trigger after the initial
check passed but before child_event->ctx was assigned, violating its
precondition. The solution is to assign child_event->ctx right after
its initial validation. This ensures the context exists for any
subsequent checks or cleanup routines, resolving the WARN_ON_ONCE().
To resolve it, defer the refcount update and child_event->ctx assignment
directly after child_event->pmu_ctx is set but before checking if the
parent event is orphaned. The cleanup routine depends on
event->pmu_ctx being non-NULL before it verifies event->ctx is
non-NULL. This also maintains the author's original intent of passing
in child_ctx to find_get_pmu_context before its refcount/assignment.
[ mingo: Expanded the changelog from another email by Gabriel Shahrouzi. ]
📍 영향받는 시스템
perf 이벤트 기능을 포함한 Linux 커널 (수정이 포함된 커널 버전 이전의 배포판 커널)
⚔️ 공격 벡터
직접적인 원격 공격 경로는 확인되지 않았으며, 로컬에서 perf 이벤트를 반복 생성·정리하는 상황에서 커널 경고(WARN) 발생 및 서비스 안정성 저하가 발생할 수 있음
🛡️ 대응 방법
배포판에서 제공하는 해당 보안 업데이트가 적용된 최신 커널로 업그레이드하고 재부팅
🔧 검증 코드
출력된 커널 버전을 배포판의 보안 권고(CVE-2025-37878 패치 포함 버전)와 대조하여, 설치된 커널이 수정 버전 이상이면 패치된 것이고 그렇지 않으면 업데이트가 필요합니다.
uname -r && (dpkg -l linux-image-$(uname -r) 2>/dev/null || rpm -q kernel 2>/dev/null)