All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
@ 2020-07-03 11:15 ` Evgeny Novikov
  0 siblings, 0 replies; 4+ messages in thread
From: Evgeny Novikov @ 2020-07-03 11:15 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Evgeny Novikov, Guenter Roeck, Joel Stanley, Andrew Jeffery,
	linux-hwmon, linux-arm-kernel, linux-aspeed, linux-kernel,
	ldv-project

aspeed_create_fan() reads a pwm_port value using of_property_read_u32().
If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be
a buffer overflow in
aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes
the potential buffer overflow.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
---
 drivers/hwmon/aspeed-pwm-tacho.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
index 33fb54845bf6..3d8239fd66ed 100644
--- a/drivers/hwmon/aspeed-pwm-tacho.c
+++ b/drivers/hwmon/aspeed-pwm-tacho.c
@@ -851,6 +851,8 @@ static int aspeed_create_fan(struct device *dev,
 	ret = of_property_read_u32(child, "reg", &pwm_port);
 	if (ret)
 		return ret;
+	if (pwm_port >= ARRAY_SIZE(pwm_port_params))
+		return -EINVAL;
 	aspeed_create_pwm_port(priv, (u8)pwm_port);
 
 	ret = of_property_count_u8_elems(child, "cooling-levels");
-- 
2.16.4


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

* [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
@ 2020-07-03 11:15 ` Evgeny Novikov
  0 siblings, 0 replies; 4+ messages in thread
From: Evgeny Novikov @ 2020-07-03 11:15 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-hwmon, ldv-project, linux-aspeed, Evgeny Novikov,
	linux-kernel, Andrew Jeffery, Joel Stanley, Guenter Roeck,
	linux-arm-kernel

aspeed_create_fan() reads a pwm_port value using of_property_read_u32().
If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be
a buffer overflow in
aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes
the potential buffer overflow.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
---
 drivers/hwmon/aspeed-pwm-tacho.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
index 33fb54845bf6..3d8239fd66ed 100644
--- a/drivers/hwmon/aspeed-pwm-tacho.c
+++ b/drivers/hwmon/aspeed-pwm-tacho.c
@@ -851,6 +851,8 @@ static int aspeed_create_fan(struct device *dev,
 	ret = of_property_read_u32(child, "reg", &pwm_port);
 	if (ret)
 		return ret;
+	if (pwm_port >= ARRAY_SIZE(pwm_port_params))
+		return -EINVAL;
 	aspeed_create_pwm_port(priv, (u8)pwm_port);
 
 	ret = of_property_count_u8_elems(child, "cooling-levels");
-- 
2.16.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
  2020-07-03 11:15 ` Evgeny Novikov
@ 2020-07-03 22:17   ` Guenter Roeck
  -1 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2020-07-03 22:17 UTC (permalink / raw)
  To: Evgeny Novikov
  Cc: Jean Delvare, Joel Stanley, Andrew Jeffery, linux-hwmon,
	linux-arm-kernel, linux-aspeed, linux-kernel, ldv-project

On Fri, Jul 03, 2020 at 02:15:18PM +0300, Evgeny Novikov wrote:
> aspeed_create_fan() reads a pwm_port value using of_property_read_u32().
> If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be
> a buffer overflow in
> aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes
> the potential buffer overflow.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/aspeed-pwm-tacho.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
> index 33fb54845bf6..3d8239fd66ed 100644
> --- a/drivers/hwmon/aspeed-pwm-tacho.c
> +++ b/drivers/hwmon/aspeed-pwm-tacho.c
> @@ -851,6 +851,8 @@ static int aspeed_create_fan(struct device *dev,
>  	ret = of_property_read_u32(child, "reg", &pwm_port);
>  	if (ret)
>  		return ret;
> +	if (pwm_port >= ARRAY_SIZE(pwm_port_params))
> +		return -EINVAL;
>  	aspeed_create_pwm_port(priv, (u8)pwm_port);
>  
>  	ret = of_property_count_u8_elems(child, "cooling-levels");

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

* Re: [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
@ 2020-07-03 22:17   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2020-07-03 22:17 UTC (permalink / raw)
  To: Evgeny Novikov
  Cc: linux-hwmon, ldv-project, Jean Delvare, linux-aspeed,
	Andrew Jeffery, linux-kernel, Joel Stanley, linux-arm-kernel

On Fri, Jul 03, 2020 at 02:15:18PM +0300, Evgeny Novikov wrote:
> aspeed_create_fan() reads a pwm_port value using of_property_read_u32().
> If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be
> a buffer overflow in
> aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes
> the potential buffer overflow.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/aspeed-pwm-tacho.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
> index 33fb54845bf6..3d8239fd66ed 100644
> --- a/drivers/hwmon/aspeed-pwm-tacho.c
> +++ b/drivers/hwmon/aspeed-pwm-tacho.c
> @@ -851,6 +851,8 @@ static int aspeed_create_fan(struct device *dev,
>  	ret = of_property_read_u32(child, "reg", &pwm_port);
>  	if (ret)
>  		return ret;
> +	if (pwm_port >= ARRAY_SIZE(pwm_port_params))
> +		return -EINVAL;
>  	aspeed_create_pwm_port(priv, (u8)pwm_port);
>  
>  	ret = of_property_count_u8_elems(child, "cooling-levels");

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-07-03 22:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 11:15 [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow Evgeny Novikov
2020-07-03 11:15 ` Evgeny Novikov
2020-07-03 22:17 ` Guenter Roeck
2020-07-03 22:17   ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.