From: Guenter Roeck <linux@roeck-us.net>
To: Anton Vasilyev <vasilyev@ispras.ru>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
ldv-project@linuxtesting.org
Subject: Re: [v2] hwmon:(stts751) buffer overread on wrong chip configuration
Date: Sun, 13 Aug 2017 06:34:48 -0700 [thread overview]
Message-ID: <20170813133448.GA4869@roeck-us.net> (raw)
In-Reply-To: <1502383592-14389-1-git-send-email-vasilyev@ispras.ru>
On Thu, Aug 10, 2017 at 07:46:32PM +0300, Anton Vasilyev wrote:
> If stts751 hw by some reason reports conversion rate bigger then 9:
> ret = i2c_smbus_read_byte_data(priv->client, STTS751_REG_RATE);
> then dereference stts751_intervals[priv->interval] leads to buffer
> overread.
>
> The path adds sanity check for value stored on chip.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Applied (after s/path/patch/)
Thanks,
Guenter
> ---
> v2: Fixed Guenter's remark about comparison
> ---
> drivers/hwmon/stts751.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/hwmon/stts751.c b/drivers/hwmon/stts751.c
> index d56251d..3f940fb 100644
> --- a/drivers/hwmon/stts751.c
> +++ b/drivers/hwmon/stts751.c
> @@ -718,6 +718,10 @@ static int stts751_read_chip_config(struct stts751_priv *priv)
> ret = i2c_smbus_read_byte_data(priv->client, STTS751_REG_RATE);
> if (ret < 0)
> return ret;
> + if (ret >= ARRAY_SIZE(stts751_intervals)) {
> + dev_err(priv->dev, "Unrecognized conversion rate 0x%x\n", ret);
> + return -ENODEV;
> + }
> priv->interval = ret;
>
> ret = stts751_read_reg16(priv, &priv->event_max,
prev parent reply other threads:[~2017-08-13 13:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 16:46 [PATCH v2] hwmon:(stts751) buffer overread on wrong chip configuration Anton Vasilyev
2017-08-13 13:34 ` Guenter Roeck [this message]
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=20170813133448.GA4869@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=ldv-project@linuxtesting.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vasilyev@ispras.ru \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox