All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: linux-hwmon@vger.kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 1/4] hwmon: (pmbus/core) increase number of phases and add new mask
Date: Fri, 11 Sep 2026 14:09:16 +0000	[thread overview]
Message-ID: <20260911140917.49D3A1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911-hwmon-max20826-support-v2-1-5e30cbd97d84@analog.com>

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

Pre-existing issues:
- [High] The PMBus core driver iterates over `info->phases[page]` to access the `info->pfunc[phase]` array without verifying that the phase count is within the `PMBUS_PHASES` maximum. If a driver configures `info->phases[page]` to a value larger than `PMBUS_PHASES`, it results in an out-of-bounds array read.
--

commit f0d55dee29cf753f56d794471093af9c4d34634d
Author: Nuno Sá <nuno.sa@analog.com>

hwmon: (pmbus/core) increase number of phases and add new mask

This commit increases the maximum number of phases per page to 16 to support
a new upcoming device. It also adds a new mask for controlling the source
of the output voltage.

> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index 2cd3216b3cd95..920c1102ab6df 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
[ ... ]
> @@ -386,7 +387,7 @@ enum pmbus_sensor_classes {
>  };
>  
>  #define PMBUS_PAGES	32	/* Per PMBus specification */
> -#define PMBUS_PHASES	10	/* Maximum number of phases per page */
> +#define PMBUS_PHASES	16	/* Maximum number of phases per page */

[Severity: High]
This isn't a bug introduced by this patch, but is it possible for a driver
to configure a phase count larger than the new PMBUS_PHASES limit and
cause an out-of-bounds read?

In drivers/hwmon/pmbus/pmbus_core.c:pmbus_add_sensor_attrs(), the loop
uses the unvalidated info->phases[page] as an upper bound to access the
statically dimensioned info->pfunc array (which is sized to PMBUS_PHASES):

				for (phase = 0; phase < info->phases[page];
				     phase++) {
					if (!(info->pfunc[phase] & attrs->func))
						continue;

If a driver calls pmbus_do_probe() with a pmbus_driver_info struct where
info->phases[page] > PMBUS_PHASES, it could result in reading past the
array bounds.

This might lead to a kernel oops during module probe or the creation of
corrupted sysfs attributes by interpreting adjacent memory as functionality
bitmasks.

Since the core framework explicitly validates info->pages > PMBUS_PAGES to
prevent similar overflows, should a similar bounds check be added for
info->phases against PMBUS_PHASES in the core API?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-hwmon-max20826-support-v2-0-5e30cbd97d84@analog.com?part=1

  reply	other threads:[~2026-09-11 14:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 13:53 [PATCH v2 0/4] hwmon: (pmbus) Add support for MAX20826 and similar devices Nuno Sá
2026-09-11 13:53 ` [PATCH v2 1/4] hwmon: (pmbus/core) increase number of phases and add new mask Nuno Sá
2026-09-11 14:09   ` sashiko-bot [this message]
2026-09-11 14:32     ` Guenter Roeck
2026-09-12 14:20   ` Guenter Roeck
2026-09-11 13:53 ` [PATCH v2 2/4] hwmon: (pmbus/core) Add mapping function to pmbus_read_block_data() Nuno Sá
2026-09-11 13:59   ` sashiko-bot
2026-09-12 14:21   ` Guenter Roeck
2026-09-11 13:53 ` [PATCH v2 3/4] dt-bindings: hwmon/pmbus: Document MAX20826 and similar devices Nuno Sá
2026-09-11 14:00   ` sashiko-bot
2026-09-12 10:21   ` Conor Dooley
2026-09-12 14:21   ` Guenter Roeck
2026-09-11 13:53 ` [PATCH v2 4/4] hwmon: (pmbus) add support for " Nuno Sá
2026-09-12 14:22   ` 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=20260911140917.49D3A1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.