From: gerben@altlinux.org
To: jagathjog1996@gmail.com
Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: [PATCH] iio: imu: bmi323: Fix potential out-of-bounds access of bmi323_hw[]
Date: Fri, 27 Mar 2026 13:32:02 +0300 [thread overview]
Message-ID: <20260327103202.459143-1-gerben@altlinux.org> (raw)
From: Denis Rastyogin <gerben@altlinux.org>
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.
Fixes: 8a636db3aa57 ("iio: imu: Add driver for BMI323 IMU")
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
drivers/iio/imu/bmi323/bmi323_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
index 6bcb9a436581..64ead4f667e0 100644
--- a/drivers/iio/imu/bmi323/bmi323_core.c
+++ b/drivers/iio/imu/bmi323/bmi323_core.c
@@ -1713,6 +1713,8 @@ static int bmi323_write_raw(struct iio_dev *indio_dev,
iio_device_release_direct(indio_dev);
return ret;
case IIO_CHAN_INFO_SCALE:
+ if (chan->type == IIO_TEMP)
+ return -EINVAL;
if (!iio_device_claim_direct(indio_dev))
return -EBUSY;
ret = bmi323_set_scale(data, bmi323_iio_to_sensor(chan->type),
--
2.42.2
reply other threads:[~2026-03-27 10:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260327103202.459143-1-gerben@altlinux.org \
--to=gerben@altlinux.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--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