lists.openwall.net   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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220623064605.2538969-1-quic_kshivnan@quicinc.com>
Date:   Thu, 23 Jun 2022 12:16:05 +0530
From:   Shivnandan Kumar <quic_kshivnan@...cinc.com>
To:     rafael@...nel.org, len.brown@...el.com, pavel@....cz
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Shivnandan Kumar <quic_kshivnan@...cinc.com>
Subject: [PATCH]     PM: QoS: Add check to make sure CPU freq is non-negative

	CPU frequency should never be non-negative.
	If some client driver calls freq_qos_update_request with some
	value greater than INT_MAX, then it will set max CPU freq at
	fmax but it will add plist node with some negative priority.
	plist node has priority from INT_MIN (highest) to INT_MAX
	(lowest). Once priority is set as negative, another client
	will not be able to reduce max CPU frequency. Adding check
	to make sure CPU freq is non-negative will fix this problem.
Signed-off-by: Shivnandan Kumar <quic_kshivnan@...cinc.com>

---
 kernel/power/qos.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index ec7e1e85923e..41e96fe34bfd 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -531,7 +531,8 @@ int freq_qos_add_request(struct freq_constraints *qos,
 {
 	int ret;
 
-	if (IS_ERR_OR_NULL(qos) || !req)
+	if (IS_ERR_OR_NULL(qos) || !req || value < FREQ_QOS_MIN_DEFAULT_VALUE
+		|| value > FREQ_QOS_MAX_DEFAULT_VALUE)
 		return -EINVAL;
 
 	if (WARN(freq_qos_request_active(req),
@@ -563,7 +564,8 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request);
  */
 int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
 {
-	if (!req)
+	if (!req || new_value < FREQ_QOS_MIN_DEFAULT_VALUE ||
+		new_value > FREQ_QOS_MAX_DEFAULT_VALUE)
 		return -EINVAL;
 
 	if (WARN(!freq_qos_request_active(req),
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ