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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Aug 2023 21:13:25 +0200
From:   "Rafael J. Wysocki" <rjw@...ysocki.net>
To:     Linux PM <linux-pm@...r.kernel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Zhang Rui <rui.zhang@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>
Subject: [PATCH v1 4/7] thermal: intel: intel_soc_dts_iosf: Change initialization ordering

From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

The initial configuration of trip points in intel_soc_dts_iosf_init()
takes place after registering the sensor thermal zones which is
potentially problematic, because it may race with the setting of trip
point temperatures via sysfs, as there is no synchronization between it
and sys_set_trip_temp().

To address this, change the initialization ordering so that the trip
points are configured prior to the registration of thermal zones.

Accordingly, change the cleanup ordering in intel_soc_dts_iosf_exit()
to remove the thermal zones before resetting the trip points.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
---
 drivers/thermal/intel/intel_soc_dts_iosf.c |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c
===================================================================
--- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c
+++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c
@@ -398,30 +398,37 @@ struct intel_soc_dts_sensors *intel_soc_
 
 	for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
 		sensors->soc_dts[i].sensors = sensors;
-		ret = add_dts_thermal_zone(i, &sensors->soc_dts[i],
-					   read_only_trip_count);
-		if (ret)
-			goto err_free;
-	}
 
-	for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
 		ret = configure_trip(&sensors->soc_dts[i], 0,
 				     THERMAL_TRIP_PASSIVE, 0);
 		if (ret)
-			goto err_remove_zone;
+			goto err_reset_trips;
 
 		ret = configure_trip(&sensors->soc_dts[i], 1,
 				     THERMAL_TRIP_PASSIVE, 0);
 		if (ret)
+			goto err_reset_trips;
+	}
+
+	for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
+		ret = add_dts_thermal_zone(i, &sensors->soc_dts[i],
+					   read_only_trip_count);
+		if (ret)
 			goto err_remove_zone;
 	}
 
 	return sensors;
+
 err_remove_zone:
 	for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i)
 		remove_dts_thermal_zone(&sensors->soc_dts[i]);
 
-err_free:
+err_reset_trips:
+	for (i = 0; i < SOC_MAX_DTS_SENSORS; i++) {
+		configure_trip(&sensors->soc_dts[i], 0, 0, 0);
+		configure_trip(&sensors->soc_dts[i], 1, 0, 0);
+	}
+
 	kfree(sensors);
 	return ERR_PTR(ret);
 }
@@ -432,9 +439,9 @@ void intel_soc_dts_iosf_exit(struct inte
 	int i;
 
 	for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
+		remove_dts_thermal_zone(&sensors->soc_dts[i]);
 		configure_trip(&sensors->soc_dts[i], 0, 0, 0);
 		configure_trip(&sensors->soc_dts[i], 1, 0, 0);
-		remove_dts_thermal_zone(&sensors->soc_dts[i]);
 	}
 	kfree(sensors);
 }



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ