🇰🇷 한글 설명
Linux 커널의 PTP(정밀 시간 프로토콜) 서브시스템에서 ptp_vclock_in_use() 함수가 ptp->n_vclocks_mux 잠금을 중복으로 획득하려 해 재귀 잠금(recursive locking) 교착 상태가 발생할 수 있는 문제입니다. 해당 함수 내의 중복된 ptp->n_vclocks 검사 로직을 제거하여 이를 해결했습니다.
💡 쉬운 설명
커널의 시간 동기화 기능에서 같은 자물쇠를 두 번 잠그려다 멈추는 버그가 있었습니다. 불필요한 검사 코드를 제거해 이 멈춤 현상을 막도록 수정되었습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ptp: remove ptp->n_vclocks check logic in ptp_vclock_in_use()
There is no disagreement that we should check both ptp->is_virtual_clock
and ptp->n_vclocks to check if the ptp virtual clock is in use.
However, when we acquire ptp->n_vclocks_mux to read ptp->n_vclocks in
ptp_vclock_in_use(), we observe a recursive lock in the call trace
starting from n_vclocks_store().
============================================
WARNING: possible recursive locking detected
6.15.0-rc6 #1 Not tainted
--------------------------------------------
syz.0.1540/13807 is trying to acquire lock:
ffff888035a24868 (&ptp->n_vclocks_mux){+.+.}-{4:4}, at:
ptp_vclock_in_use drivers/ptp/ptp_private.h:103 [inline]
ffff888035a24868 (&ptp->n_vclocks_mux){+.+.}-{4:4}, at:
ptp_clock_unregister+0x21/0x250 drivers/ptp/ptp_clock.c:415
but task is already holding lock:
ffff888030704868 (&ptp->n_vclocks_mux){+.+.}-{4:4}, at:
n_vclocks_store+0xf1/0x6d0 drivers/ptp/ptp_sysfs.c:215
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&ptp->n_vclocks_mux);
lock(&ptp->n_vclocks_mux);
*** DEADLOCK ***
....
============================================
The best way to solve this is to remove the logic that checks
ptp->n_vclocks in ptp_vclock_in_use().
The reason why this is appropriate is that any path that uses
ptp->n_vclocks must unconditionally check if ptp->n_vclocks is greater
than 0 before unregistering vclocks, and all functions are already
written this way. And in the function that uses ptp->n_vclocks, we
already get ptp->n_vclocks_mux before unregistering vclocks.
Therefore, we need to remove the redundant check for ptp->n_vclocks in
ptp_vclock_in_use() to prevent recursive locking.
📍 영향받는 시스템
수정 전의 Linux 커널 (PTP 가상 클럭 기능을 사용하는 시스템, 구체적 범위는 커널 버전별 패치 이력 확인 필요)
⚔️ 공격 벡터
로컬 사용자가 PTP 가상 클럭 관련 sysfs 인터페이스(n_vclocks)를 조작하는 경로로 커널을 교착 상태에 빠뜨려 서비스 거부(DoS)를 유발할 수 있음
🛡️ 대응 방법
배포판 보안 업데이트 또는 해당 수정 커밋이 포함된 최신 Linux 커널로 업그레이드
🔧 검증 코드
출력된 커널 버전이 배포판의 수정된 버전 이상인지 확인하고, /sys/class/ptp/ 항목이 보이면 PTP 장치가 존재하므로 해당 커널 패치 적용 여부를 우선 점검하세요.
uname -r && (ls /sys/class/ptp/ 2>/dev/null | head -5)