🇰🇷 한글 설명
Linux 커널의 8250 시리얼 드라이버에서 콘솔 핸드오버 시 런타임 PM 사용 카운트가 잘못 관리되는 문제입니다. 콘솔이 먼저 활성화된 후 실제 드라이버가 인계받는 과정에서 사용 카운트가 0인 상태로 pm_runtime_put_sync()가 호출되어 언더플로우 경고가 발생합니다. 수정은 uart_port에 dev가 설정되는 시점에 pm_runtime_get_sync()를 호출하는 것입니다.
💡 쉬운 설명
컴퓨터의 시리얼 포트 콘솔이 켜질 때 전원 관리 횟수 계산이 잘못되어 경고가 발생하는 문제입니다. 기능상 큰 위험보다는 시스템 안정성과 로그 정확성에 영향을 주는 결함입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
serial: 8250: Fix PM usage_count for console handover
When console is enabled, univ8250_console_setup() calls
serial8250_console_setup() before .dev is set to uart_port. Therefore,
it will not call pm_runtime_get_sync(). Later, when the actual driver
is going to take over univ8250_console_exit() is called. As .dev is
already set, serial8250_console_exit() makes pm_runtime_put_sync() call
with usage count being zero triggering PM usage count warning
(extra debug for univ8250_console_setup(), univ8250_console_exit(), and
serial8250_register_ports()):
[ 0.068987] univ8250_console_setup ttyS0 nodev
[ 0.499670] printk: console [ttyS0] enabled
[ 0.717955] printk: console [ttyS0] printing thread started
[ 1.960163] serial8250_register_ports assigned dev for ttyS0
[ 1.976830] printk: console [ttyS0] disabled
[ 1.976888] printk: console [ttyS0] printing thread stopped
[ 1.977073] univ8250_console_exit ttyS0 usage:0
[ 1.977075] serial8250 serial8250: Runtime PM usage count underflow!
[ 1.977429] dw-apb-uart.6: ttyS0 at MMIO 0x4010006000 (irq = 33, base_baud = 115200) is a 16550A
[ 1.977812] univ8250_console_setup ttyS0 usage:2
[ 1.978167] printk: console [ttyS0] printing thread started
[ 1.978203] printk: console [ttyS0] enabled
To fix the issue, call pm_runtime_get_sync() in
serial8250_register_ports() as soon as .dev is set for an uart_port
if it has console enabled.
This problem became apparent only recently because 82586a721595 ("PM:
runtime: Avoid device usage count underflows") added the warning
printout. I confirmed this problem also occurs with v5.18 (w/o the
warning printout, obviously).
📍 영향받는 시스템
Linux 커널 8250 시리얼 드라이버를 사용하는 시스템 (v5.18 이상 계열에서 경고 출력 가능)
⚔️ 공격 벡터
로컬 물리 접근 또는 권한을 가진 사용자가 시리얼 콘솔 관련 동작을 유발할 수 있으나, 실질적인 원격 공격 경로는 확인되지 않음
🛡️ 대응 방법
배포판 제공 최신 커널 패키지로 업데이트하거나, 수정이 포함된 Linux 커널 버전으로 업그레이드
🔧 검증 코드
출력된 커널 버전을 확인하여 배포판의 보안 권고에서 패치된 커널 버전 이상인지 비교하고, dmesg | grep -i 'usage count underflow'로 해당 경고 메시지 존재 여부를 확인