From: sashiko-bot@kernel.org
To: "Sanjay Chitroda" <sanjayembeddedse@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 04/11] iio: magnetometer: hid-sensor-magn-3d: align parenthesis for readability
Date: Tue, 16 Jun 2026 11:19:46 +0000 [thread overview]
Message-ID: <20260616111946.EEE301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616-15-jun-hid-iio-alignment-v1-4-0cd544286575@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Blindly reading 32 or 64 bits from `raw_data` without verifying `raw_len` can lead to slab-out-of-bounds reads.
--
commit 13804edb2c46947f67fe0d4d5d050f780422d2f7
Author: Sanjay Chitroda <sanjayembeddedse@gmail.com>
iio: magnetometer: hid-sensor-magn-3d: align parenthesis for readability
This commit adjusts the alignment of parentheses across multiple functions in
the hid-sensor-magn-3d driver. This improves readability and maintains
consistency with the kernel coding style.
> diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> index 23884825eb00f..82507297c55bb 100644
> --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
[ ... ]
> @@ -292,9 +291,9 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
>
> /* Capture samples in local storage */
> static int magn_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
> - u32 usage_id,
> - size_t raw_len, char *raw_data,
> - void *priv)
> + u32 usage_id,
> + size_t raw_len, char *raw_data,
> + void *priv)
> {
> struct iio_dev *indio_dev = platform_get_drvdata(priv);
> struct magn_3d_state *magn_state = iio_priv(indio_dev);
[Severity: High]
This is a pre-existing issue, but since this patch touches the signature of
magn_3d_capture_sample(), could we be at risk of a slab out-of-bounds read
further down in the function?
If a device presents a crafted HID report descriptor that defines the
HID_USAGE_SENSOR_TIME_TIMESTAMP field with a smaller size, it could result in
raw_len being less than 8. Reading 8 bytes from raw_data in this case:
case HID_USAGE_SENSOR_TIME_TIMESTAMP:
magn_state->timestamp =
hid_sensor_convert_timestamp(&magn_state->magn_flux_attributes,
*(s64 *)raw_data);
would read past the end of the buffer.
A similar dereference happens later in the function for the magnetic axes
where 4 bytes are read:
iio_val = magn_state->magn_val_addr[offset];
if (iio_val != NULL)
*iio_val = *((u32 *)raw_data);
Could this also trigger an out-of-bounds read if raw_len is smaller than 4?
Should we verify the size of raw_len before making these casts?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616-15-jun-hid-iio-alignment-v1-0-0cd544286575@gmail.com?part=4
next prev parent reply other threads:[~2026-06-16 11:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 10:26 [PATCH 00/11] HID: iio: warning clean up and prefer kernel coding style Sanjay Chitroda
2026-06-16 10:26 ` [PATCH 01/11] iio: hid-sensors: add missing blank line after declarations Sanjay Chitroda
2026-06-16 11:22 ` sashiko-bot
2026-06-16 10:26 ` [PATCH 02/11] iio: humidity: hid-sensor-humidity: align parenthesis for readability Sanjay Chitroda
2026-06-16 10:57 ` Andy Shevchenko
2026-06-16 11:22 ` sashiko-bot
2026-06-16 10:26 ` [PATCH 03/11] iio: gyro: hid-sensor-gyro-3d: " Sanjay Chitroda
2026-06-16 10:56 ` Andy Shevchenko
2026-06-16 10:26 ` [PATCH 04/11] iio: magnetometer: hid-sensor-magn-3d: " Sanjay Chitroda
2026-06-16 11:19 ` sashiko-bot [this message]
2026-06-16 10:26 ` [PATCH 05/11] iio: humidity: hid-sensor-humidity: use common device for devres Sanjay Chitroda
2026-06-16 11:27 ` sashiko-bot
2026-06-16 10:26 ` [PATCH 06/11] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda
2026-06-16 10:26 ` [PATCH 07/11] iio: temperature: hid-sensor-temperature: " Sanjay Chitroda
2026-06-16 11:27 ` sashiko-bot
2026-06-16 10:26 ` [PATCH 08/11] iio: hid-sensor-magn-3d: use ! instead of explicit NULL check Sanjay Chitroda
2026-06-16 11:01 ` Joshua Crofts
2026-06-16 10:26 ` [PATCH 09/11] iio: hid-sensor-rotation: " Sanjay Chitroda
2026-06-16 10:26 ` [PATCH 10/11] iio: hid-sensor-incl-3d: " Sanjay Chitroda
2026-06-16 11:11 ` [PATCH 11/11] iio: hid-sensor-accel-3d: " Sanjay Chitroda
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=20260616111946.EEE301F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sanjayembeddedse@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 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.