thermal: add sanity check for the passive attribute
Subsystems (3)
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
---
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
@@ -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
@@ -225,6 +225,12 @@ passive_store(struct device *dev, structif (!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) {
_
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]
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
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]
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
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.