In the Linux kernel, a crucial deadlock fix related to the clk_summary function when walking through devices in runtime Power Management (PM) has been addressed. The vulnerability identifier for this issue is CVE-2024-27003.

Overview

The Linux kernel maintains a clk framework that provides a consistent interface to manage platform clocks (clk). The clk_summary is accessible via debugfs and serves as an essential diagnostic tool for kernel developers when debugging clk-related issues. Runtime Power Management is a feature that allows devices to enter low-power states during periods of inactivity.

A deadlock situation could arise if a thread simultaneously attempts to print the clk_summary details via debugfs while another thread attempts to runtime-resume the same device. This scenario could occur when the display driver starts up as the screen is turning on.

To resolve this issue, the patch ensures that all devices are runtime-resumed before printing the clk_summary through debugfs. This change eliminates the potential deadlock situation and also fixes a bug where the return value of clk_pm_runtime_get() function was not checked, leading to RPM count underflow on error paths.

Below is a code snippet showing the changes made to address the deadlock issue in the Linux kernel

-   clk_pm_runtime_get(dev);
+   rpm_resume(dev, );

    hlist_for_each_entry_rcu(clk, p, h, core_node) {
        if (!__clk_ref_get(clk))
            continue;

        if (device_mo && !clk_core_is_enabled(clk) &&
            !clk_provider_mo)
            pm_runtime_put_autosuspend(device_mo);

+       rpm_idle(dev);

        clk_put(clk);
    }

Original references for this fix include

- Commit message
- Linux Kernel Mailing List (LKML) discussion

Exploit Details

An attacker would require access to the debugfs interface to exploit this issue actively. However, the conditions required to reproduce the deadlock are quite specific and timing-sensitive, making it difficult for an attacker to trigger the issue consistently. Nevertheless, a successful exploitation of this issue could result in a system deadlock, rendering the device unresponsive and requiring a reboot.

It is highly recommended to apply the patch related to CVE-2024-27003 for systems relying on runtime Power Management and the clk framework. The patch is already merged into the mainline Linux kernel and should be available in the upcoming stable kernel releases.

Timeline

Published on: 05/01/2024 06:15:18 UTC
Last modified on: 05/29/2024 05:26:49 UTC