Skip to contentSkip to conversation

thermal: add sanity check for the passive attribute

PATCH In review [email protected] 3 participants 6 messages Nov 17, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 8/12 thermal: add sanity check for the passive attribute

From: Frans Pop <[email protected]>

Values below 1000 milli-celsius don't make sense and can cause the system to go into a thermal heart attack: the actual temperature will always be lower and thus the system will be throttled down to its lowest setting.

An additional problem is that values below 1000 will show as 0 in /proc/acpi/thermal/TZx/trip_points:passive.

cat passive
0
echo -n 90 >passive
bash: echo: write error: Invalid argument
echo -n 90000 >passive
cat passive
90000

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13918

Cc Matthew Garrett <[email protected]>
Cc Zhang Rui <[email protected]>
Cc Len Brown <[email protected]>

---

 Documentation/thermal/sysfs-api.txt |    1 +
 drivers/thermal/thermal_sys.c       |    6 ++++++
 2 files changed, 7 insertions(+)
Documentation/thermal/sysfs-api.txt renamed from Documentation/thermal/sysfs-api.txt~thermal-add-sanity-check-for-the-passive-attribute +1 -0
diff -puN Documentation/thermal/sysfs-api.txt~thermal-add-sanity-check-for-the-passive-attribute Documentation/thermal/sysfs-api.txt
@@ -206,6 +206,7 @@ passive
 	passive trip point for the zone. Activation is done by polling with
 	an interval of 1 second.
 	Unit: millidegrees Celsius
+	Valid values: 0 (disabled) or greater than 1000
 	RW, Optional
 
 *****************************
drivers/thermal/thermal_sys.c renamed from drivers/thermal/thermal_sys.c~thermal-add-sanity-check-for-the-passive-attribute +6 -0
diff -puN drivers/thermal/thermal_sys.c~thermal-add-sanity-check-for-the-passive-attribute drivers/thermal/thermal_sys.c
@@ -225,6 +225,12 @@ passive_store(struct device *dev, struct
 	if (!sscanf(buf, "%d\n", &state))
 		return -EINVAL;
 
+	/* sanity check: values below 1000 millicelcius don't make sense
+	 * and can cause the system to go into a thermal heart attack
+	 */
+	if (state && state < 1000)
+		return -EINVAL;
+
 	if (state && !tz->forced_passive) {
 		mutex_lock(&thermal_list_lock);
 		list_for_each_entry(cdev, &thermal_cdev_list, node) {

_

#1 lore raw

As noted before, I'm not a fan of this approach - I can't think of many reasons why it'd be necessary to use temperatures below 1 degree C, but this constraint isn't present anywhere else in the thermal code and, really, there's plenty of things that people can break if they just echo incorrect values into /sys.

Signature · 1 line
Matthew Garrett | [email protected]
#2 lore raw
Quoted 5 lines · Matthew Garrett

As noted before, I'm not a fan of this approach - I can't think of many reasons why it'd be necessary to use temperatures below 1 degree C, but this constraint isn't present anywhere else in the thermal code and, really, there's plenty of things that people can break if they just echo incorrect values into /sys.

Personally I'd be in favor of adding more sanity checks rather than removing them. The cost of the check is virtually zero.

Cheers,
FJP

#3 lore raw
Quoted 9 lines · Frans Pop
Quoted 5 lines · Matthew Garrett

As noted before, I'm not a fan of this approach - I can't think of many reasons why it'd be necessary to use temperatures below 1 degree C, but this constraint isn't present anywhere else in the thermal code and, really, there's plenty of things that people can break if they just echo incorrect values into /sys.

Personally I'd be in favor of adding more sanity checks rather than removing them. The cost of the check is virtually zero.

It makes something that's potentially useful to someone impossible, for the benefit of people who can crash their system in half a dozen other ways by writing inappropriate values into other files.

Signature · 1 line
Matthew Garrett | [email protected]
#4 lore raw
Quoted 8 lines · Matthew Garrett
Quoted 7 lines · Frans Pop
Quoted 5 lines · Matthew Garrett

As noted before, I'm not a fan of this approach - I can't think of many reasons why it'd be necessary to use temperatures below 1 degree C, but this constraint isn't present anywhere else in the thermal code and, really, there's plenty of things that people can break if they just echo incorrect values into /sys.

Quoted 6 lines
Quoted 2 lines

Personally I'd be in favor of adding more sanity checks rather than removing them. The cost of the check is virtually zero.

It makes something that's potentially useful to someone impossible, for the benefit of people who can crash their system in half a dozen other ways by writing inappropriate values into other files.

If you can give me one valid use case for someone running a system with a thermal zone check below 1C I'll agree with you.

Cheers,
FJP

#5 lore raw
Quoted 12 lines · Frans Pop
Quoted 11 lines · Matthew Garrett
Quoted 9 lines · Frans Pop
Quoted 5 lines · Matthew Garrett

As noted before, I'm not a fan of this approach - I can't think of many reasons why it'd be necessary to use temperatures below 1 degree C, but this constraint isn't present anywhere else in the thermal code and, really, there's plenty of things that people can break if they just echo incorrect values into /sys.

Personally I'd be in favor of adding more sanity checks rather than removing them. The cost of the check is virtually zero.

Quoted 6 lines
Quoted 3 lines

It makes something that's potentially useful to someone impossible, for the benefit of people who can crash their system in half a dozen other ways by writing inappropriate values into other files.

If you can give me one valid use case for someone running a system with a thermal zone check below 1C I'll agree with you.

And to make it really realistic, it should be a use case which needs a value between 0 and 1 C and where a value of 1 doesn't work.