From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: gerben@altlinux.org
Cc: dlechner@baylibre.com, jagathjog1996@gmail.com, jic23@kernel.org,
nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH v2] iio: imu: bmi323: Fix potential out-of-bounds access of bmi323_hw[]
Date: Mon, 4 May 2026 14:23:04 +0300 [thread overview]
Message-ID: <afiBmFFnuABWbaKR@ashevche-desk.local> (raw)
In-Reply-To: <20260504111946.28315-1-gerben@altlinux.org>
On Mon, May 04, 2026 at 02:19:46PM +0300, gerben@altlinux.org wrote:
> The bmi323_channels[] array defines a channel with chan->type =
> IIO_TEMP and enables the IIO_CHAN_INFO_SCALE mask. As a result,
> bmi323_write_raw() may be called for this channel. However,
> bmi323_iio_to_sensor() returns -EINVAL for IIO_TEMP, and if this
> value is not validated, it can lead to an out-of-bounds access
> when used as an array index.
>
> A similar case is properly handled in bmi323_read_raw() and does
> not result in an error.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
...
> case IIO_CHAN_INFO_SAMP_FREQ:
> + ret = bmi323_iio_to_sensor(chan->type);
> + if (ret < 0)
> + return ret;
> +
> if (!iio_device_claim_direct(indio_dev))
> return -EBUSY;
> - ret = bmi323_set_odr(data, bmi323_iio_to_sensor(chan->type),
> - val, val2);
> + ret = bmi323_set_odr(data, ret, val, val2);
ret = foo(ret) is a bad style.
> iio_device_release_direct(indio_dev);
> return ret;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-05-04 11:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 11:19 [PATCH v2] iio: imu: bmi323: Fix potential out-of-bounds access of bmi323_hw[] gerben
2026-05-04 11:23 ` Andy Shevchenko [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=afiBmFFnuABWbaKR@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gerben@altlinux.org \
--cc=jagathjog1996@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=nuno.sa@analog.com \
/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