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 6/8] misc: amd-sbi: Add SBTSI ioctl register transfer interface
Date: Fri, 10 Jul 2026 11:28:09 +0000	[thread overview]
Message-ID: <20260710112809.DE5AF1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260710111642.850022-7-Akshay.Gupta@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Data race, DMA buffer corruption, and TOCTOU vulnerability due to concurrent hwmon and ioctl access to shared I3C buffers.
--

--- Patch [6]: [PATCH v4 6/8] misc: amd-sbi: Add SBTSI ioctl register transfer interface ---
commit 01a49ea8ef63627c7743953c52073396818f7f3a
Author: Prathima <Prathima.Lk@amd.com>

misc: amd-sbi: Add SBTSI ioctl register transfer interface

Implement IOCTL interface for SB-TSI driver to enable userspace access
to TSI register read/write operations through the AMD Advanced Platform
Management Link (APML) protocol.

> diff --git a/drivers/misc/amd-sbi/tsi-core.c b/drivers/misc/amd-sbi/tsi-core.c
> index 1c6f37f26d945..5c178702c67ab 100644
> --- a/drivers/misc/amd-sbi/tsi-core.c
> +++ b/drivers/misc/amd-sbi/tsi-core.c
[ ... ]
> @@ -77,7 +92,116 @@ int sbtsi_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read)
>  	if (data->is_i3c)
>  		return is_read ? sbtsi_i3c_read(data, reg, val)
>  			       : sbtsi_i3c_write(data, reg, *val);
> -
>  	return sbtsi_i2c_xfer(data, reg, val, is_read);
>  }
>  EXPORT_SYMBOL_GPL(sbtsi_xfer);
> +
> +/*
> + * The mutex protects against concurrent register transfers to the device
> + * over the shared bus.
> + */
> +static int sbtsi_xfer_ioctl(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read)
> +{
> +	guard(sbtsi)(data);
> +
> +	if (data->detached)
> +		return -ENODEV;
> +
> +	return sbtsi_xfer(data, reg, val, is_read);
> +}

[Severity: High]
The commit message mentions that the hwmon path is placed under the same
lock in the next patch, completing the serialization.

Since this patch introduces the ioctl path before the hwmon path is locked,
can an unprivileged user reading the hwmon sysfs attribute (temp1_input)
concurrently with the new SBTSI_IOCTL_REG_XFER_CMD ioctl cause data
corruption?

For I3C devices, sbtsi_xfer() calls sbtsi_i3c_read() and sbtsi_i3c_write(),
which use the shared priv->tx and priv->rx arrays for DMA transfers:

drivers/misc/amd-sbi/tsi-core.c:sbtsi_i3c_read() {
	...
	priv->tx[0] = reg;

	/* Write the register address (DMA_TO_DEVICE). */
	xfers[0].rnw = false;
	xfers[0].len = 1;
	xfers[0].data.out = priv->tx;
	...
}

Will this allow concurrent access to overwrite priv->tx while a privileged
ioctl is preparing or executing a DMA transfer, leading to buffer
corruption during git bisect?

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

  reply	other threads:[~2026-07-10 11:28 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 [this message]
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
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=20260710112809.DE5AF1F00A3A@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