linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM / sysfs: return -EINVAL for bogus strings
@ 2017-07-10  7:21 Dan Carpenter
  2017-07-10  7:29 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2017-07-10  7:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Pavel Machek, Greg Kroah-Hartman, linux-pm,
	kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 185a52581cfa..156ab57bca77 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PM / sysfs: return -EINVAL for bogus strings
  2017-07-10  7:21 [PATCH] PM / sysfs: return -EINVAL for bogus strings Dan Carpenter
@ 2017-07-10  7:29 ` Pavel Machek
  2017-07-12 21:35   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2017-07-10  7:29 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rafael J. Wysocki, Len Brown, Greg Kroah-Hartman, linux-pm,
	kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]

On Mon 2017-07-10 10:21:40, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Pavel Machek <pavel@ucw.cz>

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

> @@ -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;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PM / sysfs: return -EINVAL for bogus strings
  2017-07-10  7:29 ` Pavel Machek
@ 2017-07-12 21:35   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2017-07-12 21:35 UTC (permalink / raw)
  To: Pavel Machek, Dan Carpenter
  Cc: Len Brown, Greg Kroah-Hartman, linux-pm, kernel-janitors

On Monday, July 10, 2017 09:29:35 AM Pavel Machek wrote:
> On Mon 2017-07-10 10:21:40, Dan Carpenter wrote:
> > 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")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>
> 
> I'd suggest this is a stable candidate. It only leaks 32 bits to
> userspace, but still...
> 
> > @@ -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!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-12 21:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-10  7:21 [PATCH] PM / sysfs: return -EINVAL for bogus strings Dan Carpenter
2017-07-10  7:29 ` Pavel Machek
2017-07-12 21:35   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).