Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Edward Adam Davis" <eadavis@qq.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v5] hwmon: (aquacomputer_d5next) valid the data size before reading the sensor data
Date: Sat, 22 Aug 2026 14:20:05 +0000	[thread overview]
Message-ID: <20260822142005.BB1111F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_5F7DC370E96643AEA458177FB76E86C8F305@qq.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Incomplete bounds check leaves special-case sensor readings vulnerable to out-of-bounds reads.
- [High] Malicious HID report can trigger a NULL pointer dereference for `aquastreamxt` devices.
--

--- Patch [1]: [PATCH v5] hwmon: (aquacomputer_d5next) valid the data size before reading the sensor data ---
commit 0485af53a3a623fa52b28d4e153bb06db94d49e4
Author: Edward Adam Davis <eadavis@qq.com>

hwmon: (aquacomputer_d5next) valid the data size before reading the sensor data

This commit adds a data size check for sensor readings in the
aquacomputer_d5next driver to prevent out-of-bounds memory accesses when
processing truncated HID reports.

Link: https://syzkaller.appspot.com/bug?extid=9ee5f5dc18673d6b2f37

> diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
> index 1ca70e7262988..352b227c30159 100644
> --- a/drivers/hwmon/aquacomputer_d5next.c
> +++ b/drivers/hwmon/aquacomputer_d5next.c
> @@ -1324,6 +1324,84 @@ static const struct hwmon_chip_info aqc_chip_info = {
>  	.info = aqc_info,
>  };
>  
> +/* aqc_raw_data_valid()
> + * Does not support special-case sensor readings data size check
> + */

[Severity: High]
This is a pre-existing issue, but since this patch aims to fix out-of-bounds
reads during report processing, is it safe to leave special-case sensor
readings unvalidated?

If a malicious USB device presenting as leakshield, highflownext, or
aquastreamult sends a truncated HID report, it could pass this new generic
validation but still be too small for the special-case fields accessed later.

For example, in aqc_raw_event():

drivers/hwmon/aquacomputer_d5next.c:aqc_raw_event() {
    ...
    switch (priv->kind) {
    ...
    case leakshield:
        priv->speed_input[0] =
            ((s16)get_unaligned_be16(data + LEAKSHIELD_PRESSURE_ADJUSTED)) * 100;
    ...
}

Could this lead to another slab-out-of-bounds read if the report is too small
to contain these offsets?

> +static bool aqc_raw_data_valid(struct aqc_data *priv, int size)
> +{
> +	int off, fan_off, i;
> +
> +	if (!priv)
> +		return false;

[ ... ]

> +	/* Virtual temperature sensor */
> +	for (i = 0; i < priv->num_virtual_temp_sensors; i++) {
> +		off = priv->virtual_temp_sensor_start_offset +
> +		      i * AQC_SENSOR_SIZE + 1;
> +
> +		if (off >= size)
> +			goto invalid;
> +	}
> +
> +	/* Fan speed and related */
> +	if (!priv->fan_structure)
> +		goto flow;

[Severity: High]
This is a pre-existing issue, but does skipping this validation when
priv->fan_structure is NULL expose a NULL pointer dereference later in
aqc_raw_event()?

For devices like aquastreamxt, priv->fan_structure is NULL but priv->num_fans
is greater than 0. Later in aqc_raw_event(), the code loops over num_fans and
unconditionally dereferences fan_structure:

drivers/hwmon/aquacomputer_d5next.c:aqc_raw_event() {
    ...
    /* Fan speed and related readings */
    for (i = 0; i < priv->num_fans; i++) {
        priv->speed_input[i] =
            get_unaligned_be16(data + priv->fan_sensor_offsets[i] +
                               priv->fan_structure->speed);
    ...
}

Could this crash the kernel if a malicious USB device sends a status report
for such a device?

> +
> +	for (i = 0; i < priv->num_fans; i++) {
> +		fan_off = priv->fan_sensor_offsets[i] + 1;
> +		off = fan_off + priv->fan_structure->speed;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_5F7DC370E96643AEA458177FB76E86C8F305@qq.com?part=1

  reply	other threads:[~2026-08-22 14:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-22  3:06 [syzbot] [hwmon?] KASAN: slab-out-of-bounds Read in aqc_raw_event syzbot
2026-08-22  4:02 ` Guenter Roeck
2026-08-22  8:07   ` Aleksa Savic
2026-08-22 14:24     ` Guenter Roeck
2026-08-22  5:34 ` [PATCH] hwmon: valid the data size before reading the sensor data Edward Adam Davis
2026-08-22  5:44   ` sashiko-bot
2026-08-22  7:45     ` [PATCH v2] " Edward Adam Davis
2026-08-22  7:54       ` Guenter Roeck
2026-08-22  7:57       ` sashiko-bot
2026-08-22  9:14         ` [PATCH v3] hwmon: (aquacomputer_d5next) " Edward Adam Davis
2026-08-22  9:26           ` sashiko-bot
2026-08-22 11:34             ` [PATCH v4] " Edward Adam Davis
2026-08-22 11:47               ` sashiko-bot
2026-08-22 11:55               ` Greg KH
2026-08-22 12:23                 ` Edward Adam Davis
2026-08-22 12:45                   ` Greg KH
2026-08-22 13:03                     ` Edward Adam Davis
2026-08-22 14:05                       ` [PATCH v5] " Edward Adam Davis
2026-08-22 14:20                         ` sashiko-bot [this message]
2026-08-22 14:25                         ` Guenter Roeck
2026-08-22  6:41   ` [PATCH] hwmon: " Guenter Roeck
2026-08-22  7:54     ` Edward Adam Davis

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=20260822142005.BB1111F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eadavis@qq.com \
    --cc=linux-hwmon@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox