Skip to content

Instantly share code, notes, and snippets.

@c0ldn3s5
Created July 15, 2026 22:19
Show Gist options
  • Select an option

  • Save c0ldn3s5/845f65e3e645ed7737b5c7f0734bae0b to your computer and use it in GitHub Desktop.

Select an option

Save c0ldn3s5/845f65e3e645ed7737b5c7f0734bae0b to your computer and use it in GitHub Desktop.
Kali bug 0009784: power-profiles-daemon amd-pstate global boost fix
diff --git a/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-pristine-0.30/src/ppd-driver-amd-pstate.c b/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-analysis/src/ppd-driver-amd-pstate.c
index 6ed597e..58030eb 100644
--- a/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-pristine-0.30/src/ppd-driver-amd-pstate.c
+++ b/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-analysis/src/ppd-driver-amd-pstate.c
@@ -17,6 +17,7 @@
#define CPUFREQ_POLICY_DIR "/sys/devices/system/cpu/cpufreq/"
#define PSTATE_STATUS_PATH "/sys/devices/system/cpu/amd_pstate/status"
+#define CPUFREQ_BOOST_PATH "/sys/devices/system/cpu/cpufreq/boost"
struct _PpdDriverAmdPstate
{
@@ -196,6 +197,9 @@ apply_pref_to_devices (GPtrArray *devices,
const char *min_freq;
g_autofree char *status = NULL;
g_autofree char *pstate_status_path = NULL;
+ g_autofree char *boost = NULL;
+ g_autofree char *boost_path = NULL;
+ gboolean per_policy_boost_writable = TRUE;
if (profile == PPD_PROFILE_UNSET)
return TRUE;
@@ -209,6 +213,10 @@ apply_pref_to_devices (GPtrArray *devices,
return TRUE;
}
+ boost_path = ppd_utils_get_sysfs_path (CPUFREQ_BOOST_PATH);
+ if (g_file_get_contents (boost_path, &boost, NULL, NULL))
+ per_policy_boost_writable = g_strcmp0 (g_strchomp (boost), "0") != 0;
+
epp_pref = profile_to_epp_pref (profile, battery);
gov_pref = profile_to_gov_pref (profile);
cpb_pref = profile_to_cpb_pref (profile);
@@ -236,7 +244,7 @@ apply_pref_to_devices (GPtrArray *devices,
return FALSE;
cpb = g_build_filename (base, "boost", NULL);
- if (g_file_test (cpb, G_FILE_TEST_EXISTS)) {
+ if (per_policy_boost_writable && g_file_test (cpb, G_FILE_TEST_EXISTS)) {
if (!ppd_utils_write (cpb, cpb_pref, error))
return FALSE;
}
diff --git a/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-pristine-0.30/tests/integration_test.py b/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-analysis/tests/integration_test.py
index 0994cf2..959cb92 100644
--- a/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-pristine-0.30/tests/integration_test.py
+++ b/home/c0ld/bug-bounty/deets/kali-amd-pstate-report-2026-07-15/source-analysis/tests/integration_test.py
@@ -1392,6 +1392,48 @@ class Tests(dbusmock.DBusTestCase):
self.assert_file_eventually_contains(scaling_governor, "powersave")
self.assert_file_eventually_contains(boost, "0")
+ def test_amd_pstate_global_boost_disabled(self):
+ """AMD P-State profiles work when global boost is disabled"""
+
+ cpufreq_dir = os.path.join(
+ self.testbed.get_root_dir(), "sys/devices/system/cpu/cpufreq"
+ )
+ os.makedirs(cpufreq_dir)
+ self.write_file_contents(os.path.join(cpufreq_dir, "boost"), "0\n")
+
+ policy_dir = os.path.join(cpufreq_dir, "policy0")
+ os.makedirs(policy_dir)
+ self.write_file_contents(os.path.join(policy_dir, "boost"), "0\n")
+ self.write_file_contents(
+ os.path.join(policy_dir, "scaling_governor"), "performance\n"
+ )
+ self.write_file_contents(
+ os.path.join(policy_dir, "energy_performance_preference"),
+ "performance\n",
+ )
+
+ pstate_dir = os.path.join(
+ self.testbed.get_root_dir(), "sys/devices/system/cpu/amd_pstate"
+ )
+ os.makedirs(pstate_dir)
+ self.write_file_contents(os.path.join(pstate_dir, "status"), "active\n")
+
+ self.start_daemon()
+ self.set_dbus_property(
+ "ActiveProfile", GLib.Variant.new_string("power-saver")
+ )
+
+ self.assertEqual(self.get_dbus_property("ActiveProfile"), "power-saver")
+ self.assert_file_eventually_contains(
+ os.path.join(policy_dir, "energy_performance_preference"), "power"
+ )
+ self.assert_file_eventually_contains(
+ os.path.join(policy_dir, "scaling_governor"), "powersave"
+ )
+ self.assertEqual(
+ self.read_file_contents(os.path.join(policy_dir, "boost")), b"0\n"
+ )
+
def test_amd_pstate_balance(self):
"""AMD P-State driver (balance)"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment