lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 26 Dec 2017 12:56:26 +0530
From:   gaurav jindal <>
Subject: [PATCH]cpuidle: preventive check in cpuidle_select against crash

When selecting the idle state using cpuidle_select, there is no
check on cpuidle_curr_governor. In cpuidle_switch_governor,
cpuidle_currr_governor can be set to NULL to specify "disabled".

Since cpuidle_select cannot return negative value, it has to return 0
in case of error. Printing logs and returning can help in debugging and
preventing possible kernel crash scenarios.

Signed-off-by: Gaurav Jindal<>


diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 68a1682..bf08e3a 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -268,6 +268,19 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
 int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
+	/* Since negative return is not allowed
+	 * we have to return 0 even if the
+	 * framework cannot select the idle state
+	 */
+	if (!cpuidle_curr_governor) {
+		pr_err("idle governor is disabled\n");
+		return 0;
+	}
+	if (!cpuidle_curr_governor->select) {
+		pr_err("idle governor select is NULL\n");
+		return 0;
+	}
 	return cpuidle_curr_governor->select(drv, dev);

Powered by blists - more mailing lists