Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vas Zayarskiy" <contact@vasily.cc>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v4 1/5] hwmon: (aquacomputer_d5next) Avoid truncating scaled sensor readings
Date: Sun, 27 Sep 2026 18:46:31 +0000	[thread overview]
Message-ID: <20260927184631.DBB7D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927183723.4078226-2-contact@vasily.cc>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hwmon: TOCTOU race in aqc_read() exposes -ENODATA to userspace
--

commit 33794227f1f473259c7900f38a511561b017b28c
Author: Vas Zayarskiy <contact@vasily.cc>

    hwmon: (aquacomputer_d5next) Avoid truncating scaled sensor readings

    High Flow Next power is reported in watts. Multiplying the 16-bit value
    by one million can overflow both the signed intermediate and the u32
    cache. Store power in long, perform the conversion in u64, and clamp to
    LONG_MAX. The other existing power conversions fit in a signed 32-bit
    value. Return -ENODATA for unavailable power instead of exposing the
    stored error as a reading.

> diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
> index 1ca70e7262988..9178ac4cbdd75 100644
> --- a/drivers/hwmon/aquacomputer_d5next.c
> +++ b/drivers/hwmon/aquacomputer_d5next.c
[ ... ]
> @@ -1070,6 +1071,8 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
>  		}
>  		break;
>  	case hwmon_power:
> +		if (priv->power_input[channel] == -ENODATA)
> +			return -ENODATA;
>  		*val = priv->power_input[channel];

[Severity: Medium]
Could a concurrent HID raw event interrupt update priv->power_input[channel]
to -ENODATA right after the validation check but before the assignment?

If aqc_raw_event() updates the shared state concurrently, it seems this TOCTOU
race in aqc_read() could cause the internal -ENODATA error code to be returned
to userspace as a valid power reading (because aqc_read returns 0 on success).

Should this read be protected with READ_ONCE() or a lock to prevent exposing
transient incorrect statistics when userspace polls the sysfs file?

>  		break;
>  	case hwmon_pwm:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927183723.4078226-1-contact@vasily.cc?part=1

  reply	other threads:[~2026-09-27 18:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 18:37 [PATCH v4 0/5] hwmon: AMPINEL telemetry support and shared fixes Vas Zayarskiy
2026-09-27 18:37 ` [PATCH v4 1/5] hwmon: (aquacomputer_d5next) Avoid truncating scaled sensor readings Vas Zayarskiy
2026-09-27 18:46   ` sashiko-bot [this message]
2026-09-27 18:37 ` [PATCH v4 2/5] hwmon: (aquacomputer_d5next) Expire the initial sensor cache Vas Zayarskiy
2026-09-27 18:47   ` sashiko-bot
2026-09-27 18:37 ` [PATCH v4 3/5] hwmon: (aquacomputer_d5next) Validate incoming status reports Vas Zayarskiy
2026-09-27 18:49   ` sashiko-bot
2026-09-27 18:37 ` [PATCH v4 4/5] hwmon: (aquacomputer_d5next) Skip unknown firmware version offsets Vas Zayarskiy
2026-09-27 18:46   ` sashiko-bot
2026-09-27 18:37 ` [PATCH v4 5/5] hwmon: (aquacomputer_d5next) Add AMPINEL telemetry support Vas Zayarskiy
2026-09-27 18:46   ` sashiko-bot

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=20260927184631.DBB7D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=contact@vasily.cc \
    --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