🇰🇷 한글 설명
Linux 커널의 cpufreq 구성 요소에서 정책 cpumask가 초기화되지 않은 상태로 sysfs에 노출되는 취약점이 발견되었습니다. 이로 인해 초기화되지 않은 메모리의 쓰레기 값이 포함된 비트맵이 sysfs를 통해 접근 가능해질 수 있습니다.
💡 쉬운 설명
컴퓨터의 CPU 속도를 조절하는 설정 파일이 준비되기도 전에 미리 공개되어 버리는 문제입니다. 이로 인해 시스템이 잘못된 정보를 읽어 들여 오작동할 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
cpufreq: zero-initialize policy cpumask before sysfs publication
cpufreq_policy_alloc() allocates policy->cpus with alloc_cpumask_var(),
i.e. without __GFP_ZERO, unlike the sibling related_cpus and real_cpus
masks. With CONFIG_CPUMASK_OFFSTACK=y the mask is a separate
kmalloc_node() allocation, so its bitmap holds whatever the slab allocator
left behind:
cpufreq_online()
cpufreq_policy_alloc()
alloc_cpumask_var(&policy->cpus) /* bitmap is uninitialized */
kobject_init_and_add() /* policy%u/ appears in sysfs */
cpufreq_policy_online()
cpumask_copy(policy->cpus, cpumask_of(cpu)) /* first valid value */
This leaves a window in which the sysfs attributes are already reachable
while policy->cpus is still garbage. show()/store() gate on
policy_is_inactive(), i.e. cpumask_empty(policy->cpus), so a non-zero
bitmap makes them run the attribute callbacks on a policy that is not
initialized yet.
Fix this by using zalloc_cpumask_var() for policy->cpus.
📍 영향받는 시스템
CONFIG_CPUMASK_OFFSTACK=y 설정이 활성화된 Linux 커널
⚔️ 공격 벡터
초기화되지 않은 커널 메모리(slab allocator의 잔여 데이터)를 통해 sysfs 속성에 접근하여 비정상적인 동작 유도
🛡️ 대응 방법
cpufreq_policy_alloc() 함수에서 alloc_cpumask_var() 대신 zalloc_cpumask_var()를 사용하여 메모리를 0으로 초기화하도록 커널 패치 적용
🔧 검증 코드
커널 버전과 CONFIG_CPUMASK_OFFSTACK 설정이 y로 되어 있는지 확인하여 취약 가능성을 검토합니다.
uname -a && grep CONFIG_CPUMASK_OFFSTACK /boot/config-$(uname -r) 2>/dev/null