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]
Date:   Tue,  4 Oct 2022 10:18:43 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     linux-pm@...r.kernel.org
Cc:     "Rafael J . Wysocki" <rafael@...nel.org>,
        Amit Kucheria <amitk@...nel.org>,
        Zhang Rui <rui.zhang@...el.com>, linux-kernel@...r.kernel.org,
        Guenter Roeck <linux@...ck-us.net>,
        Daniel Lezcano <daniel.lezcano@...aro.org>
Subject: [PATCH] thermal/core: Fix parameter check when setting trip point temperatures

Commit 9326167058e8a ("thermal/core: Move set_trip_temp ops to the sysfs
code") changed the parameter check in trip_point_temp_store() from

	if (!tz->ops->set_trip_temp)

to
	if (!tz->ops->set_trip_temp && !tz->trips)

That means the condition will pass if either tz->ops->set_trip_temp
or tz->trips is not NULL. Subsequently, access to tz->trips is
checked again, but tz->ops->set_trip_temp is called unconditionally.
This will result in a crash if the set_trip_temp callback is not set.
Add check if tz->ops->set_trip_temp is NULL before trying to call it.

Fixes: 9326167058e8a ("thermal/core: Move set_trip_temp ops to the sysfs code")
Cc: Daniel Lezcano <daniel.lezcano@...aro.org>
Signed-off-by: Guenter Roeck <linux@...ck-us.net>
---
 drivers/thermal/thermal_sysfs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 78c5841bdfae..ec495c7dff03 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -128,9 +128,11 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
 	if (kstrtoint(buf, 10, &temperature))
 		return -EINVAL;
 
-	ret = tz->ops->set_trip_temp(tz, trip, temperature);
-	if (ret)
-		return ret;
+	if (tz->ops->set_trip_temp) {
+		ret = tz->ops->set_trip_temp(tz, trip, temperature);
+		if (ret)
+			return ret;
+	}
 
 	if (tz->trips)
 		tz->trips[trip].temperature = temperature;
-- 
2.36.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ