Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (pmbus/adm1266) serialize firmware_revision debugfs read with pmbus_lock
Date: Wed, 20 May 2026 18:18:33 +0000	[thread overview]
Message-ID: <20260520181833.9D15F1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260520-adm1266-fwrev-fix-v1-1-8a78c94a53ef@nexthop.ai>

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

Pre-existing issues:
- [Critical] Out-of-bounds memory read/write and logic bug in `adm1266_gpio_get_multiple()`.
- [High] Direct device accessors lack the `pmbus_lock` required for serialization, contradicting the commit message.
- [High] GPIO and NVMEM devices are exposed to userspace before PMBus probe is complete, creating a race condition.
--

commit 93431d6d47217063e4487061d81fc6df727bcdb0
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>

hwmon: (pmbus/adm1266) serialize firmware_revision debugfs read with pmbus_lock

adm1266_firmware_revision_read() backs the firmware_revision debugfs
entry and issues an i2c_smbus_read_block_data() without taking pmbus_lock.
This patch adds guard(pmbus_lock)(client) to serialize the read.

>     Take pmbus_lock at the top of adm1266_firmware_revision_read()
>     via the scope-based guard(), matching the pattern just applied to
>     adm1266_state_read() and the GPIO/NVMEM accessors.

[Severity: High]
This isn't a bug introduced by this patch, but the commit message asserts that
the guard(pmbus_lock) pattern was "just applied to adm1266_state_read() and the
GPIO/NVMEM accessors."

Does the current code actually do this? Looking at adm1266_state_read(),
adm1266_gpio_get(), adm1266_gpio_get_multiple(), and
adm1266_nvmem_read_blackbox(), they do not appear to use pmbus_lock. This
omission leaves direct I2C accesses unprotected and vulnerable to interleaving
with pmbus_core's multi-transaction sequences, which can corrupt hardware state
or interrupt PMBus transactions.

[Severity: High]
This is a pre-existing issue, but are GPIO and NVMEM devices exposed to
userspace before PMBus probe is complete?

In adm1266_probe(), adm1266_config_gpio() and adm1266_config_nvmem() are called
before pmbus_do_probe(). These functions register their respective devices,
immediately exposing them to userspace.

If userspace accesses these interfaces early, do the accessors run before PMBus
core structures are fully initialized? If the missing pmbus_lock were added to
these accessors (as the commit message assumes it was), wouldn't it retrieve a
NULL pointer from i2c_get_clientdata() and dereference it during pmbus_lock(),
causing a kernel crash?

[Severity: Critical]
This is a pre-existing issue, but is there an out-of-bounds memory read/write
and logic bug in adm1266_gpio_get_multiple()?

In adm1266_gpio_get_multiple(), the second bit-iteration loop incorrectly uses
the PMBus command byte ADM1266_PDIO_STATUS (0xE9 = 233) instead of the correct
pin count macro ADM1266_PDIO_NR (16) as the loop's upper limit.

Does this cause for_each_set_bit_from() to iterate up to bit 242? Since the
mask and bits variables from the GPIO subsystem are sized only for ngpio (25
bits, which fits in 1 unsigned long), does this result in out-of-bounds reads
on mask and out-of-bounds writes on bits via set_bit(), leading to severe
memory corruption?

Furthermore, doesn't executing *bits = 0; immediately before the second loop
inadvertently wipe out all the valid pin states gathered during the first loop?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260520-adm1266-fwrev-fix-v1-1-8a78c94a53ef@nexthop.ai?part=1

      parent reply	other threads:[~2026-05-20 18:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 17:38 [PATCH] hwmon: (pmbus/adm1266) serialize firmware_revision debugfs read with pmbus_lock Abdurrahman Hussain
2026-05-20 17:49 ` Guenter Roeck
2026-05-20 18:18 ` 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=20260520181833.9D15F1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abdurrahman@nexthop.ai \
    --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