From: sashiko-bot@kernel.org
To: "Carlo Caione" <ccaione@baylibre.com>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-amlogic@lists.infradead.org, robh@kernel.org,
conor+dt@kernel.org, neil.armstrong@linaro.org
Subject: Re: [PATCH 2/7] clk: meson: pll: Support PLLs without a pre-divider
Date: Fri, 06 Nov 2026 08:35:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-201071@kernel.org> (raw)
In-Reply-To: <20261106-upstream-s7-clk-v1-2-7d501d62621f@baylibre.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] clk: meson: 32-bit integer overflow in
meson_clk_get_pll_range_index() [1]
--
commit 241035ecfdb206acdcf290a5e288104a056a3f8b
Author: Carlo Caione <ccaione@baylibre.com>
clk: meson: pll: Support PLLs without a pre-divider
This commit makes the PLL pre-divider parameter optional in the common Meson
PLL driver, defaulting the divider to 1 when the parameter is not applicable.
> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
> index 1ea6579a760f3..44b33051405f5 100644
> --- a/drivers/clk/meson/clk-pll.c
> +++ b/drivers/clk/meson/clk-pll.c
[ ... ]
> @@ -174,7 +176,7 @@ static int meson_clk_get_pll_range_index(unsigned long rate,
> *n = index + 1;
>
> /* Check the predivider range */
> - if (*n >= (1 << pll->n.width))
> + if (*n >= (MESON_PARM_APPLICABLE(&pll->n) ? 1 << pll->n.width : 2))
> return -EINVAL;
>
> if (*n == 1) {
[Severity: High]
This problem wasn't introduced by this patch, but can `pll->range->max *
parent_rate` in meson_clk_get_pll_range_index() and `parent_rate * m` in
__pll_params_with_frac() overflow 32-bit unsigned long arithmetic [1]?
drivers/clk/meson/clk-pll.c:meson_clk_get_pll_range_index() {
...
if (*n == 1) {
/* Get the boundaries out the way */
if (rate <= pll->range->min * parent_rate) {
*m = pll->range->min;
return -ENODATA;
} else if (rate >= pll->range->max * parent_rate) {
*m = pll->range->max;
return -ENODATA;
}
}
...
}
drivers/clk/meson/clk-pll.c:__pll_params_with_frac() {
...
/* Bail out if we are already over the requested rate */
if (rate < parent_rate * m / n)
return 0;
...
}
On 32-bit architectures, multiplying a 24 MHz `parent_rate` by a typical
multiplier (such as `pll->range->max` of 250) reaches 6,000,000,000 and wraps
around 32-bit `ULONG_MAX`. This causes the range check in
meson_clk_get_pll_range_index() to miscalculate `m` and the guard in
__pll_params_with_frac() to be bypassed, underflowing `val -= m * frac_max`
and writing corrupted multiplier and fractional values to the PLL hardware.
[1] https://sashiko.dev/#/bug/linux-8a5ec432-efbd-4d3f-83c7-2a50fc2850c7
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-upstream-s7-clk-v1-0-7d501d62621f@baylibre.com?part=2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Carlo Caione" <ccaione@baylibre.com>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-amlogic@lists.infradead.org, robh@kernel.org,
conor+dt@kernel.org, neil.armstrong@linaro.org
Subject: Re: [PATCH 2/7] clk: meson: pll: Support PLLs without a pre-divider
Date: Fri, 06 Nov 2026 08:35:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-201071@kernel.org> (raw)
In-Reply-To: <20261106-upstream-s7-clk-v1-2-7d501d62621f@baylibre.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] clk: meson: 32-bit integer overflow in
meson_clk_get_pll_range_index() [1]
--
commit 241035ecfdb206acdcf290a5e288104a056a3f8b
Author: Carlo Caione <ccaione@baylibre.com>
clk: meson: pll: Support PLLs without a pre-divider
This commit makes the PLL pre-divider parameter optional in the common Meson
PLL driver, defaulting the divider to 1 when the parameter is not applicable.
> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
> index 1ea6579a760f3..44b33051405f5 100644
> --- a/drivers/clk/meson/clk-pll.c
> +++ b/drivers/clk/meson/clk-pll.c
[ ... ]
> @@ -174,7 +176,7 @@ static int meson_clk_get_pll_range_index(unsigned long rate,
> *n = index + 1;
>
> /* Check the predivider range */
> - if (*n >= (1 << pll->n.width))
> + if (*n >= (MESON_PARM_APPLICABLE(&pll->n) ? 1 << pll->n.width : 2))
> return -EINVAL;
>
> if (*n == 1) {
[Severity: High]
This problem wasn't introduced by this patch, but can `pll->range->max *
parent_rate` in meson_clk_get_pll_range_index() and `parent_rate * m` in
__pll_params_with_frac() overflow 32-bit unsigned long arithmetic [1]?
drivers/clk/meson/clk-pll.c:meson_clk_get_pll_range_index() {
...
if (*n == 1) {
/* Get the boundaries out the way */
if (rate <= pll->range->min * parent_rate) {
*m = pll->range->min;
return -ENODATA;
} else if (rate >= pll->range->max * parent_rate) {
*m = pll->range->max;
return -ENODATA;
}
}
...
}
drivers/clk/meson/clk-pll.c:__pll_params_with_frac() {
...
/* Bail out if we are already over the requested rate */
if (rate < parent_rate * m / n)
return 0;
...
}
On 32-bit architectures, multiplying a 24 MHz `parent_rate` by a typical
multiplier (such as `pll->range->max` of 250) reaches 6,000,000,000 and wraps
around 32-bit `ULONG_MAX`. This causes the range check in
meson_clk_get_pll_range_index() to miscalculate `m` and the guard in
__pll_params_with_frac() to be bypassed, underflowing `val -= m * frac_max`
and writing corrupted multiplier and fractional values to the PLL hardware.
[1] https://sashiko.dev/#/bug/linux-8a5ec432-efbd-4d3f-83c7-2a50fc2850c7
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-upstream-s7-clk-v1-0-7d501d62621f@baylibre.com?part=2
next prev parent reply other threads:[~2026-11-06 8:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 8:30 [PATCH 0/7] Add Amlogic S7 clock controllers Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-06 8:30 ` [PATCH 1/7] dt-bindings: clock: Add Amlogic S7 SCMI clock IDs Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-08 23:21 ` Conor Dooley
2026-11-08 23:21 ` Conor Dooley
2026-11-09 8:37 ` Jerome Brunet
2026-11-09 8:37 ` Jerome Brunet
2026-11-09 20:00 ` Conor Dooley
2026-11-09 20:00 ` Conor Dooley
2026-11-09 20:59 ` Carlo Caione
2026-11-09 20:59 ` Carlo Caione
2026-11-09 8:49 ` Carlo Caione
2026-11-09 8:49 ` Carlo Caione
2026-11-06 8:30 ` [PATCH 2/7] clk: meson: pll: Support PLLs without a pre-divider Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-06 8:35 ` sashiko-bot [this message]
2026-11-06 8:35 ` sashiko-bot
2026-11-06 8:30 ` [PATCH 3/7] clk: meson: pll: Support active-low resets Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-06 8:30 ` [PATCH 4/7] dt-bindings: clock: Add Amlogic S7 PLL clock controller Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-06 17:35 ` Conor Dooley
2026-11-06 17:35 ` Conor Dooley
2026-11-08 23:21 ` Conor Dooley
2026-11-08 23:21 ` Conor Dooley
2026-11-06 8:30 ` [PATCH 5/7] clk: amlogic: Add S7 PLL clock controller driver Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-06 8:51 ` sashiko-bot
2026-11-06 8:51 ` sashiko-bot
2026-11-06 8:30 ` [PATCH 6/7] dt-bindings: clock: Add Amlogic S7 peripherals clock controller Carlo Caione
2026-11-06 8:30 ` Carlo Caione
2026-11-06 17:34 ` Conor Dooley
2026-11-06 17:34 ` Conor Dooley
2026-11-06 19:34 ` Carlo Caione
2026-11-06 19:34 ` Carlo Caione
2026-11-06 20:48 ` Conor Dooley
2026-11-06 20:48 ` Conor Dooley
2026-11-06 22:27 ` Carlo Caione
2026-11-06 22:27 ` Carlo Caione
2026-11-08 23:17 ` Conor Dooley
2026-11-08 23:17 ` Conor Dooley
2026-11-06 8:30 ` [PATCH 7/7] clk: amlogic: Add S7 peripherals clock controller driver Carlo Caione
2026-11-06 8:30 ` Carlo Caione
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=sashiko-outbox-201071@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ccaione@baylibre.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--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.