Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Akshay Gupta" <Akshay.Gupta@amd.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v4 7/8] hwmon: Add mutex protecting for sbtsi read/write through hwmon
Date: Fri, 10 Jul 2026 11:37:02 +0000	[thread overview]
Message-ID: <20260710113703.61B131F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710111642.850022-8-Akshay.Gupta@amd.com>

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

Pre-existing issues:
- [High] Integer overflow in `sbtsi_write` when `ext_range_mode` is enabled, causing large inputs to be incorrectly clamped to minimum.
--

--- Patch [7]: [PATCH v4 7/8] hwmon: Add mutex protecting for sbtsi read/write through hwmon ---
commit 8772051459eabab96983f02f6316165d79c69002
Author: Prathima <Prathima.Lk@amd.com>

hwmon: Add mutex protecting for sbtsi read/write through hwmon

This commit adds a mutex and takes it around SBTSI read/write paths so that
only one transaction runs at a time. The lock is held only for the duration 
of the bus transfer and associated driver bookkeeping.

> diff --git a/drivers/hwmon/sbtsi_temp.c b/drivers/hwmon/sbtsi_temp.c
> index d7ae986d824c4..11c8108d69b2a 100644
> --- a/drivers/hwmon/sbtsi_temp.c
> +++ b/drivers/hwmon/sbtsi_temp.c
[ ... ]
> @@ -84,6 +85,7 @@ static int sbtsi_temp_write(struct sbtsi_data *data, u8 reg_int, u8 reg_dec,
>  {
>  	int ret;
>  
> +	guard(sbtsi)(data);
>  	ret = sbtsi_xfer(data, reg_int, &val_int, false);
>  	if (!ret)
>  		ret = sbtsi_xfer(data, reg_dec, &val_dec, false);

[Severity: High]
This isn't a bug introduced by this patch, but does this code overflow val
in the caller sbtsi_write()?

If data->ext_range_mode is enabled, a large user input val is increased without
a prior upper-bound check:

drivers/hwmon/sbtsi_temp.c:sbtsi_write() {
    ...
	if (data->ext_range_mode)
		val += SBTSI_TEMP_EXT_RANGE_ADJ;
	val = clamp_val(val, SBTSI_TEMP_MIN, SBTSI_TEMP_MAX);
    ...
}

Writing a large maximum value to the hwmon sysfs limit causes a signed 
integer overflow when adding the adjustment value.

The resulting negative number is passed to clamp_val, which incorrectly clamps
it to zero.

This sets the hardware temperature limit to zero degrees Celsius, which can 
instantly trigger thermal throttling or a hardware thermal shutdown.

A user or management script legitimately trying to disable or maximize the limit
by writing the maximum possible integer will unintentionally trigger a thermal 
alert instead.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260710111642.850022-1-Akshay.Gupta@amd.com?part=7

  reply	other threads:[~2026-07-10 11:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 11:16 [PATCH v4 0/8] misc: amd-sbi: Refactor SBTSI driver with I3C support and ioctl interface Akshay Gupta
2026-07-10 11:16 ` [PATCH v4 1/8] hwmon/misc: amd-sbi: Move core sbtsi support from hwmon to misc Akshay Gupta
2026-07-10 11:26   ` sashiko-bot
2026-07-10 14:26   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 2/8] hwmon: sbtsi_temp: Refactor temperature register access into helpers Akshay Gupta
2026-07-10 11:30   ` sashiko-bot
2026-07-10 14:27   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 3/8] hwmon/misc: amd-sbi: Move sbtsi register transfer to core abstraction Akshay Gupta
2026-07-10 11:25   ` sashiko-bot
2026-07-10 14:28   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 4/8] misc: amd-sbi: Consolidate Common SBTSI Probe Path Akshay Gupta
2026-07-10 11:25   ` sashiko-bot
2026-07-10 11:16 ` [PATCH v4 5/8] misc: amd-sbi: Add support for SB-TSI over I3C Akshay Gupta
2026-07-10 11:34   ` sashiko-bot
2026-07-10 11:16 ` [PATCH v4 6/8] misc: amd-sbi: Add SBTSI ioctl register transfer interface Akshay Gupta
2026-07-10 11:28   ` sashiko-bot
2026-07-10 11:16 ` [PATCH v4 7/8] hwmon: Add mutex protecting for sbtsi read/write through hwmon Akshay Gupta
2026-07-10 11:37   ` sashiko-bot [this message]
2026-07-10 14:28   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 8/8] docs: misc: amd-sbi: Document SBTSI userspace interface Akshay Gupta
2026-07-10 11:35   ` 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=20260710113703.61B131F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Akshay.Gupta@amd.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