Skip to contentSkip to conversation

PM / sysfs: return -EINVAL for bogus strings

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 10, 2017 – Jul 12, 2017

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

PATCH 1/1 PM / sysfs: return -EINVAL for bogus strings

In the current code, if the user accidentally writes a bogus command to this sysfs file, then we set the latency tolerance to an uninitialized variable.

Fixes 2d984ad132a8 ("PM / QoS: Introcuce latency tolerance device PM QoS type")
drivers/base/power/sysfs.c +2 -0
index 185a52581cfa..156ab57bca77 100644
@@ -272,6 +272,8 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
 			value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
 		else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))
 			value = PM_QOS_LATENCY_ANY;
+		else
+			return -EINVAL;
 	}
 	ret = dev_pm_qos_update_user_latency_tolerance(dev, value);
 	return ret < 0 ? ret : n;
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

In the current code, if the user accidentally writes a bogus command to this sysfs file, then we set the latency tolerance to an uninitialized variable.

Fixes 2d984ad132a8 ("PM / QoS: Introcuce latency tolerance device PM QoS type")

I'd suggest this is a stable candidate. It only leaks 32 bits to userspace, but still...

Quoted 9 lines
drivers/base/power/sysfs.c +2 -0
@@ -272,6 +272,8 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
 			value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
 		else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))
 			value = PM_QOS_LATENCY_ANY;
+		else
+			return -EINVAL;
 	}
 	ret = dev_pm_qos_update_user_latency_tolerance(dev, value);
 	return ret < 0 ? ret : n;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 13 lines · Pavel Machek
Quoted 6 lines · Dan Carpenter

In the current code, if the user accidentally writes a bogus command to this sysfs file, then we set the latency tolerance to an uninitialized variable.

Fixes 2d984ad132a8 ("PM / QoS: Introcuce latency tolerance device PM QoS type")

I'd suggest this is a stable candidate. It only leaks 32 bits to userspace, but still...

Quoted 11 lines

drivers/base/power/sysfs.c static ssize_t pm_qos_latency_tolerance_store(struct device *dev, · line 279

Quoted 9 lines
drivers/base/power/sysfs.c +2 -0
@@ -272,6 +272,8 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
 			value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
 		else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))
 			value = PM_QOS_LATENCY_ANY;
+		else
+			return -EINVAL;
 	}
 	ret = dev_pm_qos_update_user_latency_tolerance(dev, value);
 	return ret < 0 ? ret : n;

Applied, thanks!