All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Evgeny Novikov <novikov@ispras.ru>
Cc: Jean Delvare <jdelvare@suse.com>, Joel Stanley <joel@jms.id.au>,
	Andrew Jeffery <andrew@aj.id.au>,
	linux-hwmon@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
Date: Fri, 3 Jul 2020 15:17:44 -0700	[thread overview]
Message-ID: <20200703221744.GA34644@roeck-us.net> (raw)
In-Reply-To: <20200703111518.9644-1-novikov@ispras.ru>

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");

WARNING: multiple messages have this Message-ID
From: Guenter Roeck <linux@roeck-us.net>
To: Evgeny Novikov <novikov@ispras.ru>
Cc: linux-hwmon@vger.kernel.org, ldv-project@linuxtesting.org,
	Jean Delvare <jdelvare@suse.com>,
	linux-aspeed@lists.ozlabs.org, Andrew Jeffery <andrew@aj.id.au>,
	linux-kernel@vger.kernel.org, Joel Stanley <joel@jms.id.au>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
Date: Fri, 3 Jul 2020 15:17:44 -0700	[thread overview]
Message-ID: <20200703221744.GA34644@roeck-us.net> (raw)
In-Reply-To: <20200703111518.9644-1-novikov@ispras.ru>

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

  reply	other threads:[~2020-07-03 22:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 11:15 Evgeny Novikov
2020-07-03 11:15 ` Evgeny Novikov
2020-07-03 22:17 ` Guenter Roeck [this message]
2020-07-03 22:17   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200703221744.GA34644@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=andrew@aj.id.au \
    --cc=jdelvare@suse.com \
    --cc=joel@jms.id.au \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=novikov@ispras.ru \
    --subject='Re: [PATCH] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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.