From: sashiko-bot@kernel.org
To: "Akshay Gupta" <Akshay.Gupta@amd.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v4 8/8] docs: misc: amd-sbi: Document SBTSI userspace interface
Date: Fri, 10 Jul 2026 11:35:22 +0000 [thread overview]
Message-ID: <20260710113522.872F91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710111642.850022-9-Akshay.Gupta@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The I3C transmit buffer (`tx`) is used for DMA but is not cacheline aligned, leading to DMA false sharing with adjacent fields in `struct sbtsi_data`.
- [High] A race condition between `misc_open()` and devres driver unbind causes a use-after-free of `struct sbtsi_data`.
--
--- Patch [8]: [PATCH v4 8/8] docs: misc: amd-sbi: Document SBTSI userspace interface ---
commit 0d1e3dd1fee7d42c8bd4c97352ebe1b9dc763f55
Author: Prathima <Prathima.Lk@amd.com>
Subject: docs: misc: amd-sbi: Document SBTSI userspace interface
This commit documents the SBTSI userspace interface and implements the SB-TSI
driver for AMD SoCs. It adds an ioctl interface to perform I2C/I3C register
transfers and creates a miscdevice node for each sensor. It also registers an
auxiliary device to bind with the hwmon driver.
Link: https://github.com/amd/esmi_oob_library [1]
Link: https://www.amd.com/en/developer/e-sms.html [2]
> diff --git a/drivers/misc/amd-sbi/tsi-core.c b/drivers/misc/amd-sbi/tsi-core.c
> new file mode 100644
> index 0000000000000..5c178702c67ab
> --- /dev/null
> +++ b/drivers/misc/amd-sbi/tsi-core.c
> @@ -0,0 +1,207 @@
[ ... ]
> +/* I3C read transfer function */
> +static int sbtsi_i3c_read(struct sbtsi_data *data, u8 reg, u8 *val)
> +{
> + struct sbtsi_i3c_priv *priv = to_sbtsi_i3c_priv(data);
> + struct i3c_xfer xfers[2] = { };
> + int ret;
> +
> + 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;
> +
> + /* Read the data byte into a separate buffer (DMA_FROM_DEVICE). */
> + xfers[1].rnw = true;
> + xfers[1].len = 1;
> + xfers[1].data.in = &priv->rx;
> +
> + ret = i3c_device_do_xfers(data->i3cdev, xfers, 2, I3C_SDR);
[Severity: High]
Does this code lack cacheline alignment for the tx buffer?
Looking at the structure definition in drivers/misc/amd-sbi/tsi-core.h:
struct sbtsi_i3c_priv {
struct sbtsi_data data;
u8 tx[2];
u8 rx __aligned(ARCH_DMA_MINALIGN);
};
Since tx lacks __aligned(ARCH_DMA_MINALIGN), it shares a cacheline with the
preceding fields in struct sbtsi_data. Because tx is used here as a
DMA_TO_DEVICE buffer, couldn't DMA cache maintenance operations on tx
corrupt adjacent fields like kref or lock on non-cache-coherent
architectures?
> + if (ret)
> + return ret;
> +
> + *val = priv->rx;
> + return ret;
> +}
[ ... ]
> +static int sbtsi_open(struct inode *inode, struct file *fp)
> +{
> + struct sbtsi_data *data;
> +
> + data = container_of(fp->private_data, struct sbtsi_data, sbtsi_misc_dev);
> + scoped_guard(sbtsi, data) {
[Severity: High]
Is it possible for a concurrent device unbind to free struct sbtsi_data
before sbtsi_open() acquires the mutex?
If misc_open() sets fp->private_data and drops the core misc_mtx, and then
devres executes sbtsi_driver_unref() (which drops the final reference and
frees data), would sbtsi_open() accessing data->lock result in a
use-after-free?
drivers/misc/amd-sbi/tsi.c:sbtsi_driver_unref() {
struct sbtsi_data *data = arg;
kref_put(&data->kref, sbtsi_data_release);
}
> + if (data->detached)
> + return -ENODEV;
> + }
> +
> + kref_get(&data->kref);
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710111642.850022-1-Akshay.Gupta@amd.com?part=8
prev parent reply other threads:[~2026-07-10 11:35 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
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 [this message]
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=20260710113522.872F91F000E9@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