Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: qcom: Add missing post divider table sentinels
@ 2026-11-25 21:34 Vladimir Zapolskiy
  2026-11-25 21:34 ` [PATCH 1/2] clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables Vladimir Zapolskiy
  2026-11-25 21:34 ` [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table Vladimir Zapolskiy
  0 siblings, 2 replies; 8+ messages in thread
From: Vladimir Zapolskiy @ 2026-11-25 21:34 UTC (permalink / raw)
  To: Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Bryan O'Donoghue,
	Dmitry Baryshkov, Taniya Das, Melody Olvera, linux-arm-msm,
	linux-clk

Two Qualcomm clock drivers have post divider tables without a sentinel
entry, while the clock divider helpers walk a table until a zero
divider is found, add the missing sentinels.

Vladimir Zapolskiy (2):
  clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables
  clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table

 drivers/clk/qcom/camcc-sc8280xp.c | 9 +++++++++
 drivers/clk/qcom/gcc-qdu1000.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables
  2026-11-25 21:34 [PATCH 0/2] clk: qcom: Add missing post divider table sentinels Vladimir Zapolskiy
@ 2026-11-25 21:34 ` Vladimir Zapolskiy
  2026-11-27 11:40   ` Bryan O'Donoghue
  2026-11-25 21:34 ` [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table Vladimir Zapolskiy
  1 sibling, 1 reply; 8+ messages in thread
From: Vladimir Zapolskiy @ 2026-11-25 21:34 UTC (permalink / raw)
  To: Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Bryan O'Donoghue,
	Dmitry Baryshkov, Taniya Das, Melody Olvera, linux-arm-msm,
	linux-clk

The PLL post divider tables are passed to divider_determine_rate() from
.determine_rate of clk_alpha_pll_postdiv_lucid_ops, and the generic
clock divider helpers iterate over a table until they find an entry with
a zero divider, however the tables are not terminated by an empty entry.

This may lead to the out-of-bounds access by setting a rate of a clock,
which is supplied by a PLL post divider, for instance a rate change of
IFE, BPS or IPE clocks propagates to camcc_pll{0,3,4,5,6}_out_even
clocks, since the RCGs and post dividers have CLK_SET_RATE_PARENT flag.

Adding the missing sentinels to all post divider tables fixes the issue.

Fixes: ff93872a9c61 ("clk: qcom: camcc-sc8280xp: Add sc8280xp CAMCC")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
 drivers/clk/qcom/camcc-sc8280xp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/clk/qcom/camcc-sc8280xp.c b/drivers/clk/qcom/camcc-sc8280xp.c
index b0f1d40d1df5..131e5d1a1879 100644
--- a/drivers/clk/qcom/camcc-sc8280xp.c
+++ b/drivers/clk/qcom/camcc-sc8280xp.c
@@ -85,6 +85,7 @@ static struct clk_alpha_pll camcc_pll0 = {
 
 static const struct clk_div_table post_div_table_camcc_pll0_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll0_out_even = {
@@ -107,6 +108,7 @@ static struct clk_alpha_pll_postdiv camcc_pll0_out_even = {
 
 static const struct clk_div_table post_div_table_camcc_pll0_out_odd[] = {
 	{ 0x3, 3 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll0_out_odd = {
@@ -160,6 +162,7 @@ static struct clk_alpha_pll camcc_pll1 = {
 
 static const struct clk_div_table post_div_table_camcc_pll1_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll1_out_even = {
@@ -238,6 +241,7 @@ static struct clk_alpha_pll camcc_pll3 = {
 
 static const struct clk_div_table post_div_table_camcc_pll3_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll3_out_even = {
@@ -291,6 +295,7 @@ static struct clk_alpha_pll camcc_pll4 = {
 
 static const struct clk_div_table post_div_table_camcc_pll4_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll4_out_even = {
@@ -344,6 +349,7 @@ static struct clk_alpha_pll camcc_pll5 = {
 
 static const struct clk_div_table post_div_table_camcc_pll5_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll5_out_even = {
@@ -397,6 +403,7 @@ static struct clk_alpha_pll camcc_pll6 = {
 
 static const struct clk_div_table post_div_table_camcc_pll6_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll6_out_even = {
@@ -450,6 +457,7 @@ static struct clk_alpha_pll camcc_pll7 = {
 
 static const struct clk_div_table post_div_table_camcc_pll7_out_even[] = {
 	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll7_out_even = {
@@ -472,6 +480,7 @@ static struct clk_alpha_pll_postdiv camcc_pll7_out_even = {
 
 static const struct clk_div_table post_div_table_camcc_pll7_out_odd[] = {
 	{ 0x3, 3 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv camcc_pll7_out_odd = {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table
  2026-11-25 21:34 [PATCH 0/2] clk: qcom: Add missing post divider table sentinels Vladimir Zapolskiy
  2026-11-25 21:34 ` [PATCH 1/2] clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables Vladimir Zapolskiy
@ 2026-11-25 21:34 ` Vladimir Zapolskiy
  2026-11-27 11:04   ` Konrad Dybcio
  2026-11-27 11:41   ` Bryan O'Donoghue
  1 sibling, 2 replies; 8+ messages in thread
From: Vladimir Zapolskiy @ 2026-11-25 21:34 UTC (permalink / raw)
  To: Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Bryan O'Donoghue,
	Dmitry Baryshkov, Taniya Das, Melody Olvera, linux-arm-msm,
	linux-clk

The GPLL0 even output post divider table is not terminated by an empty
entry, the table is passed to divider_determine_rate(), and the generic
clock divider helpers iterate over a table until they find an entry with
a zero divider, thus they may read past the end of the array.

Add the missing sentinel to the table to fix the issue.

Fixes: 1c9efb0bc040 ("clk: qcom: Add QDU1000 and QRU1000 GCC support")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
 drivers/clk/qcom/gcc-qdu1000.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/qcom/gcc-qdu1000.c b/drivers/clk/qcom/gcc-qdu1000.c
index 4dfc67280611..6f44f4cc9968 100644
--- a/drivers/clk/qcom/gcc-qdu1000.c
+++ b/drivers/clk/qcom/gcc-qdu1000.c
@@ -65,7 +65,8 @@ static struct clk_alpha_pll gcc_gpll0 = {
 };
 
 static const struct clk_div_table post_div_table_gcc_gpll0_out_even[] = {
-	{ 0x1, 2 }
+	{ 0x1, 2 },
+	{ }
 };
 
 static struct clk_alpha_pll_postdiv gcc_gpll0_out_even = {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table
  2026-11-25 21:34 ` [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table Vladimir Zapolskiy
@ 2026-11-27 11:04   ` Konrad Dybcio
  2026-11-27 11:40     ` Bryan O'Donoghue
  2026-11-27 12:03     ` Vladimir Zapolskiy
  2026-11-27 11:41   ` Bryan O'Donoghue
  1 sibling, 2 replies; 8+ messages in thread
From: Konrad Dybcio @ 2026-11-27 11:04 UTC (permalink / raw)
  To: Vladimir Zapolskiy, Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Bryan O'Donoghue,
	Dmitry Baryshkov, Taniya Das, Melody Olvera, linux-arm-msm,
	linux-clk

On 11/25/26 10:34 PM, Vladimir Zapolskiy wrote:
> The GPLL0 even output post divider table is not terminated by an empty
> entry, the table is passed to divider_determine_rate(), and the generic
> clock divider helpers iterate over a table until they find an entry with
> a zero divider, thus they may read past the end of the array.

But there's a .num_post_div?

Konrad

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table
  2026-11-27 11:04   ` Konrad Dybcio
@ 2026-11-27 11:40     ` Bryan O'Donoghue
  2026-11-27 12:03     ` Vladimir Zapolskiy
  1 sibling, 0 replies; 8+ messages in thread
From: Bryan O'Donoghue @ 2026-11-27 11:40 UTC (permalink / raw)
  To: Konrad Dybcio, Vladimir Zapolskiy, Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Dmitry Baryshkov,
	Taniya Das, Melody Olvera, linux-arm-msm, linux-clk

On 27/11/2026 11:04, Konrad Dybcio wrote:
> On 11/25/26 10:34 PM, Vladimir Zapolskiy wrote:
>> The GPLL0 even output post divider table is not terminated by an empty
>> entry, the table is passed to divider_determine_rate(), and the generic
>> clock divider helpers iterate over a table until they find an entry with
>> a zero divider, thus they may read past the end of the array.
> 
> But there's a .num_post_div?
> 
> Konrad

I think divider_determine_rate() takes the bare table and requires the 
sentinel.

A more salient point is why there is a difference at all. TBH I thought 
the sentinel was stylistic not functional but, it seems that is not so, 
there are two differing interpretations of the same data.

Should be one of those consistently...

Actually include/linux/clk-provider.h:716

/**
  * struct clk_divider - adjustable divider clock
  *
  * @hw:         handle between common and hardware-specific interfaces
  * @reg:        register containing the divider
  * @shift:      shift to the divider bit field
  * @width:      width of the divider bit field
  * @table:      array of value/divider pairs, last entry should have 
div = 0
  * @lock:       register lock

=> every table should have a last dummy entry

---
bod

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables
  2026-11-25 21:34 ` [PATCH 1/2] clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables Vladimir Zapolskiy
@ 2026-11-27 11:40   ` Bryan O'Donoghue
  0 siblings, 0 replies; 8+ messages in thread
From: Bryan O'Donoghue @ 2026-11-27 11:40 UTC (permalink / raw)
  To: Vladimir Zapolskiy, Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Dmitry Baryshkov,
	Taniya Das, Melody Olvera, linux-arm-msm, linux-clk

On 25/11/2026 21:34, Vladimir Zapolskiy wrote:
> The PLL post divider tables are passed to divider_determine_rate() from
> .determine_rate of clk_alpha_pll_postdiv_lucid_ops, and the generic
> clock divider helpers iterate over a table until they find an entry with
> a zero divider, however the tables are not terminated by an empty entry.
> 
> This may lead to the out-of-bounds access by setting a rate of a clock,
> which is supplied by a PLL post divider, for instance a rate change of
> IFE, BPS or IPE clocks propagates to camcc_pll{0,3,4,5,6}_out_even
> clocks, since the RCGs and post dividers have CLK_SET_RATE_PARENT flag.
> 
> Adding the missing sentinels to all post divider tables fixes the issue.
> 
> Fixes: ff93872a9c61 ("clk: qcom: camcc-sc8280xp: Add sc8280xp CAMCC")
> Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table
  2026-11-25 21:34 ` [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table Vladimir Zapolskiy
  2026-11-27 11:04   ` Konrad Dybcio
@ 2026-11-27 11:41   ` Bryan O'Donoghue
  1 sibling, 0 replies; 8+ messages in thread
From: Bryan O'Donoghue @ 2026-11-27 11:41 UTC (permalink / raw)
  To: Vladimir Zapolskiy, Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Dmitry Baryshkov,
	Taniya Das, Melody Olvera, linux-arm-msm, linux-clk

On 25/11/2026 21:34, Vladimir Zapolskiy wrote:
> The GPLL0 even output post divider table is not terminated by an empty
> entry, the table is passed to divider_determine_rate(), and the generic
> clock divider helpers iterate over a table until they find an entry with
> a zero divider, thus they may read past the end of the array.
> 
> Add the missing sentinel to the table to fix the issue.
> 
> Fixes: 1c9efb0bc040 ("clk: qcom: Add QDU1000 and QRU1000 GCC support")
> Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table
  2026-11-27 11:04   ` Konrad Dybcio
  2026-11-27 11:40     ` Bryan O'Donoghue
@ 2026-11-27 12:03     ` Vladimir Zapolskiy
  1 sibling, 0 replies; 8+ messages in thread
From: Vladimir Zapolskiy @ 2026-11-27 12:03 UTC (permalink / raw)
  To: Konrad Dybcio, Bjorn Andersson, Abel Vesa
  Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Bryan O'Donoghue,
	Dmitry Baryshkov, Taniya Das, Melody Olvera, linux-arm-msm,
	linux-clk

On 11/27/26 13:04, Konrad Dybcio wrote:
> On 11/25/26 10:34 PM, Vladimir Zapolskiy wrote:
>> The GPLL0 even output post divider table is not terminated by an empty
>> entry, the table is passed to divider_determine_rate(), and the generic
>> clock divider helpers iterate over a table until they find an entry with
>> a zero divider, thus they may read past the end of the array.
> 
> But there's a .num_post_div?

That is used by driver/clk/qcom/clk-alpha-pll.c internally. In fact, and
in my opinion, it might be better to remove it and to rely on a sentinel
only, if you also find it wanted and acceptable.

And if you look at clk_trion_pll_postdiv_determine_rate() or
clk_alpha_pll_postdiv_fabia_determine_rate(), then, as it is stated, it
becomes clear that the table without the sentinel is passed down to clock
framework functions, and that's the critical problem fixed by this changeset.

-- 
Best wishes,
Vladimir

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-27 12:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 21:34 [PATCH 0/2] clk: qcom: Add missing post divider table sentinels Vladimir Zapolskiy
2026-11-25 21:34 ` [PATCH 1/2] clk: qcom: camcc-sc8280xp: Add sentinels to post divider tables Vladimir Zapolskiy
2026-11-27 11:40   ` Bryan O'Donoghue
2026-11-25 21:34 ` [PATCH 2/2] clk: qcom: gcc-qdu1000: Add sentinel to GPLL0 even post divider table Vladimir Zapolskiy
2026-11-27 11:04   ` Konrad Dybcio
2026-11-27 11:40     ` Bryan O'Donoghue
2026-11-27 12:03     ` Vladimir Zapolskiy
2026-11-27 11:41   ` Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox