🇰🇷 한글 설명
Linux 커널의 ac100 RTC 드라이버에서 프로브(probe) 실패 시 클록 제공자가 해제되지 않아 발생하는 Use-After-Free 취약점입니다. 클록 제공자가 전역 목록에 남아 해제된 메모리를 참조하게 되며, 이로 인해 시스템 불안정성이나 메모리 누수가 발생할 수 있습니다.
💡 쉬운 설명
장치를 처음 실행할 때 오류가 발생하면, 사용하던 메모리를 제대로 정리하지 않고 남겨두는 버그입니다. 이 때문에 나중에 시스템이 이미 사라진 메모리 정보를 다시 읽으려다 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
rtc: ac100: Fix clock provider use-after-free on probe failure
ac100_rtc_register_clks() registers the RTC-32k clock with
clk_hw_register_fixed_rate() and the clock provider with
of_clk_add_hw_provider(). Neither is device managed, and both are
released only from ac100_rtc_remove(). The driver core does not call
remove() when probe() fails: really_probe() reaches probe_failed below
the device_remove() call and goes straight to releasing the device's
managed resources.
ac100_rtc_probe() ends with
return devm_rtc_register_device(chip->rtc);
so if that fails after the clocks have been registered, the provider is
left on the global of_clk_providers list holding chip->clk_data, which
was allocated with devm_kzalloc() and is freed while probe() unwinds. A
later lookup on this device tree node then reads freed memory in
of_clk_hw_onecell_get(). Consumers that do exactly that exist in tree:
the wifi power sequence nodes on sun8i-a83t-bananapi-m3 and
sun8i-a83t-cubietruck-plus take <&ac100_rtc 1>, and the sun9i-a80 boards
route osc32k through <&ac100_rtc 0>. The window is narrow, as
devm_rtc_register_device() can only fail with -ENOMEM here, but the
provider is left dangling whenever it does.
The RTC-32k clock is leaked on the same path. Since clk_core_lookup()
searches a global list that is not scoped per device, __clk_register()
rejects the duplicate name with -EEXIST, so the leak also makes a later
probe of the same device fail.
The error path that returns -EINVAL when the ADDA 4M parent clock cannot
be found leaks the RTC-32k clock in the same way. No provider has been
registered at that point, so that one is a leak rather than a
use-after-free.
Register both with devm_clk_hw_register_fixed_rate() and
devm_of_clk_add_hw_provider() so that they are released whenever the
device goes away, on a failed probe as well as on unbind. Devres
releases in reverse order of acquisition, so the provider is removed
before chip->clk_data is freed, and the clkout children are now
unregistered before their parent rather than after it.
ac100_rtc_unregister_clks() and the remove callback then have nothing
left to do and are removed.
📍 영향받는 시스템
Linux kernel (ac100 RTC driver 포함 버전)
⚔️ 공격 벡터
프로브 단계에서 메모리 할당 실패(-ENOMEM)를 유도하여 Use-After-Free 상태를 유발
🛡️ 대응 방법
클록 등록 함수를 devm_ 기반의 관리형 함수(devm_clk_hw_register_fixed_rate, devm_of_clk_add_hw_provider)로 교체하여 자동 해제되도록 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 패치된 최신 보안 업데이트 버전인지 확인하십시오.