From: sashiko-bot@kernel.org
To: "Ali Ahmet Memis" <ali@iusegentoo.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (corsair-psu) serialize debugfs access against hwmon
Date: Sun, 02 Aug 2026 12:48:19 +0000 [thread overview]
Message-ID: <20260802124819.D796B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260802123653.19532-1-ali@iusegentoo.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The shared `priv->cmd_buffer` is modified concurrently by process context and interrupt/softirq context without synchronization, leading to data races and hardware state machine corruption.
- [Medium] Missing null termination for USB-provided strings allows an out-of-bounds read in debugfs.
--
--- Patch [1]: [PATCH] hwmon: (corsair-psu) serialize debugfs access against hwmon ---
commit 99da3eb40b38c5c1f4427842c0633cb5ade4ac3c
Author: Ali Ahmet Memis <ali@iusegentoo.com>
hwmon: (corsair-psu) serialize debugfs access against hwmon
This commit adds guard(hwmon_lock)(priv->hwmon_dev) to debugfs read
operations to serialize them against other hwmon subsystem calls. The hwmon
core serializes its own callers, but the debugfs files call
corsairpsu_get_value() directly.
Link: https://lore.kernel.org/all/5f0406fa-9692-49f0-bcfe-c013f5fc7b62@roeck-us.net/
Link: https://lore.kernel.org/all/agR9YW7hGTJ_l7ms@monster.localdomain/
> diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c
> index ce958cdaef58a..24100519cd834 100644
> --- a/drivers/hwmon/corsair-psu.c
> +++ b/drivers/hwmon/corsair-psu.c
[ ... ]
[Severity: High]
This is a pre-existing issue, but can this sequence lead to data corruption?
Looking at corsairpsu_usb_cmd(), the completion is reinitialized before
the command is transmitted:
drivers/hwmon/corsair-psu.c:corsairpsu_usb_cmd() {
...
reinit_completion(&priv->wait_completion);
ret = hid_hw_output_report(priv->hdev, priv->cmd_buffer, CMD_BUFFER_SIZE);
...
}
If a delayed or spurious HID report arrives during this window,
corsairpsu_raw_event() will see completion_done() as false:
drivers/hwmon/corsair-psu.c:corsairpsu_raw_event() {
...
if (completion_done(&priv->wait_completion))
return 0;
memcpy(priv->cmd_buffer, data, min(CMD_BUFFER_SIZE, size));
complete(&priv->wait_completion);
...
}
Will this asynchronous overwrite corrupt the shared cmd_buffer while it is
being transmitted via hid_hw_output_report(), and cause the driver to process
a delayed reply as the answer to the new command?
[Severity: Medium]
This is a pre-existing issue, but does this copy guarantee null termination
for string fields?
When populating string fields like priv->vendor, 24 bytes (REPLY_SIZE) are
copied directly from the USB response:
drivers/hwmon/corsair-psu.c:corsairpsu_usb_cmd() {
...
if (data)
memcpy(data, priv->cmd_buffer + 2, REPLY_SIZE);
return 0;
}
If a non-compliant or malicious USB device provides exactly 24 non-null
characters, there won't be a null terminator.
When the debugfs file is read later, could this result in an out-of-bounds
read that leaks adjacent kernel memory to userspace?
drivers/hwmon/corsair-psu.c:vendor_show() {
...
seq_printf(seqf, "%s\n", priv->vendor);
return 0;
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260802123653.19532-1-ali@iusegentoo.com?part=1
next prev parent reply other threads:[~2026-08-02 12:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 12:36 [PATCH] hwmon: (corsair-psu) serialize debugfs access against hwmon Ali Ahmet Memis
2026-08-02 12:48 ` sashiko-bot [this message]
2026-08-02 12:57 ` Wilken Gottwalt
2026-08-02 14:07 ` Guenter Roeck
2026-08-03 23:19 ` Guenter Roeck
2026-08-03 23:56 ` Ali Ahmet Memis
2026-08-04 2:54 ` Guenter Roeck
2026-08-04 4:11 ` Wilken Gottwalt
2026-08-04 9:47 ` Ali Ahmet Memis
2026-08-04 10:06 ` Ali Ahmet Memis
2026-08-04 16:34 ` Guenter Roeck
2026-08-04 17:53 ` Wilken Gottwalt
2026-08-04 18:37 ` Wilken Gottwalt
2026-08-04 20:14 ` Guenter Roeck
2026-08-06 5:23 ` Wilken Gottwalt
2026-08-06 9:23 ` Guenter Roeck
2026-08-06 12:19 ` Wilken Gottwalt
2026-08-06 14:10 ` Wilken Gottwalt
2026-08-06 14:21 ` [PATCH v2] " Ali Ahmet Memis
2026-08-06 14:35 ` sashiko-bot
2026-08-06 15:41 ` Guenter Roeck
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=20260802124819.D796B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ali@iusegentoo.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