🇰🇷 한글 설명
Linux 커널의 charger-manager 구성 요소에서 전원 공급 장치(sysfs)가 등록되기 전에 레귤레이터가 해제되거나, 해제된 후에도 접근이 가능한 Use-After-Free 취약점이 존재합니다. 이로 인해 시스템 종료 또는 드라이버 제거 과정에서 이미 해제된 메모리 핸들을 참조하여 커널 패닉이나 권한 상승이 발생할 수 있습니다.
💡 쉬운 설명
충전기 관리 프로그램이 종료될 때, 이미 사용이 끝난 메모리 주소를 다시 사용하려고 시도하면서 발생하는 오류입니다. 이 과정에서 시스템이 갑자기 멈추거나 해커가 시스템 제어권을 얻을 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
power: supply: charger-manager: register regulators before exposing sysfs
charger_manager_remove() and the err_reg_extcon probe error path free each
charger regulator with regulator_put() before tearing down the power_supply
sysfs entries (power_supply_unregister()). charger_manager_remove() also
calls try_charger_enable(cm, false) after the regulator_put() loop. A
concurrent write to a charger's externally_control sysfs attribute that
lands between regulator_put() and power_supply_unregister() can run
charger_externally_control_store() and call try_charger_enable(), which,
when charging is enabled, dereferences the already-freed consumer handle.
When charging is enabled, try_charger_enable(cm, false) in .remove() also
dereferences the freed handles directly. Both leave use-after-free windows.
Symmetrically, probe registers the sysfs entries (power_supply_register)
before acquiring the regulators (regulator_get, inside
charger_manager_register_extcon), so userspace can reach externally_control
before the regulators are available.
Split charger_manager_register_extcon() on the sync/async boundary:
charger_manager_get_regulators() (regulator_get only, no async producer)
now runs before power_supply_register() so sysfs is not live before
regulators are available, and charger_manager_register_extcon() keeps only
the extcon notifier/work setup, still after power_supply_register() so a
power_supply_register() failure cannot reach extcon setup. This keeps the
sysfs setup/teardown ordering symmetric without introducing an asynchronous
producer on the earlier probe-error path.
Move power_supply_unregister() and try_charger_enable(cm, false) ahead of
the regulator_put() loop on both teardown paths, and adjust err_reg_extcon
(power_supply_unregister() then fall through err_regulator for
regulator_put(); get_regulators self-rolls back on its own failure).
This does not address the separate extcon-notifier-driven deref of the same
handles, which needs its own synchronization design.
Found by an in-house static analysis tool.
📍 영향받는 시스템
Linux Kernel (charger-manager 구성 요소를 사용하는 시스템)
⚔️ 공격 벡터
충전기의 sysfs 속성(externally_control)에 대한 동시 쓰기 작업을 통한 Use-After-Free 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 sysfs 등록 및 레귤레이터 해제 순서를 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인합니다.