linux/drivers/clk
Gustavo A. R. Silva 397d887c16 clk: visconti: Add bounds-checking coverage for struct visconti_pll_provider
In order to gain the bounds-checking coverage that __counted_by provides
to flexible-array members at run-time via CONFIG_UBSAN_BOUNDS (for array
indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions),
we must make sure that the counter member, in this particular case `num`,
is updated before the first access to the flex-array member, in this
particular case array `hws`. See below:

commit f316cdff8d ("clk: Annotate struct clk_hw_onecell_data with
__counted_by") introduced `__counted_by` for `struct clk_hw_onecell_data`
together with changes to relocate some of assignments of counter `num`
before `hws` is accessed:

include/linux/clk-provider.h:
1380 struct clk_hw_onecell_data {
1381         unsigned int num;
1382         struct clk_hw *hws[] __counted_by(num);
1383 };

However, this structure is used as a member in other structs, in this
case in `struct visconti_pll_provider`:

drivers/clk/visconti/pll.h:
 16 struct visconti_pll_provider {
 17         void __iomem *reg_base;
 18         struct device_node *node;
 19
 20         /* Must be last */
 21         struct clk_hw_onecell_data clk_data;
 22 };

Hence, we need to move the assignments to `ctx->clk_data.num` after
allocation for `struct visconti_pll_provider` and before accessing the
flexible array `ctx->clk_data.hws`. And, as assignments for all members
in `struct visconti_pll_provider` are originally adjacent to each other,
relocate all assignments together, so we don't split up
`ctx->clk_data.hws = nr_plls` from the rest. :)

Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/e3189f3e40e8723b6d794fb2260e2e9ab6b960bd.1697492890.git.gustavoars@kernel.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
2023-10-23 19:40:20 -07:00
..
actions clk: actions: Convert to devm_platform_ioremap_resource() 2023-08-22 14:28:03 -07:00
analogbits
at91 Merge branches 'clk-qcom' and 'clk-microchip' into clk-next 2023-06-26 16:36:14 -07:00
axis
axs10x clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
baikal-t1 clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
bcm clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
berlin clk: berlin: div: Add a determine_rate hook 2023-06-08 18:39:26 -07:00
davinci clk: da8xx: clk48: Switch to determine_rate 2023-06-08 18:39:34 -07:00
hisilicon clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
imgtec
imx This pull request is full of clk driver changes. In fact, there aren't any 2023-08-30 19:53:39 -07:00
ingenic clk: ingenic: tcu: Switch to determine_rate 2023-06-08 18:39:34 -07:00
keystone This pull request is full of clk driver changes. In fact, there aren't any 2023-08-30 19:53:39 -07:00
mediatek This pull request is full of clk driver changes. In fact, there aren't any 2023-08-30 19:53:39 -07:00
meson This pull request is full of clk driver changes. In fact, there aren't any 2023-08-30 19:53:39 -07:00
microchip clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
mmp clk: pxa910: Move number of clocks to driver source 2023-08-22 14:14:17 -07:00
mstar clk: mstar: msc313 cpupll clk driver 2022-10-27 11:44:27 -07:00
mvebu Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
mxs
nuvoton clk: nuvoton: Convert to devm_platform_ioremap_resource() 2023-08-22 14:52:11 -07:00
nxp
pistachio
pxa ARM: SoC changes for 6.5 2023-06-29 15:28:33 -07:00
qcom Merge branch 'clk-qcom' into clk-next 2023-08-30 14:39:58 -07:00
ralink clk: Annotate struct clk_hw_onecell_data with __counted_by 2023-08-22 13:51:26 -07:00
renesas Merge branches 'clk-bindings', 'clk-starfive', 'clk-rm', 'clk-renesas' and 'clk-cleanup' into clk-next 2023-08-30 14:37:45 -07:00
rockchip Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
samsung Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
sifive clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
socfpga clk: socfpga: agilex: Convert to devm_platform_ioremap_resource() 2023-08-22 14:28:34 -07:00
spear clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
sprd clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
st clk: st: flexgen: Switch to determine_rate 2023-06-08 18:39:35 -07:00
starfive Merge branches 'clk-bindings', 'clk-starfive', 'clk-rm', 'clk-renesas' and 'clk-cleanup' into clk-next 2023-08-30 14:37:45 -07:00
stm32 clk: stm32: composite: Switch to determine_rate 2023-06-08 18:39:35 -07:00
sunxi Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
sunxi-ng Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
tegra Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
ti Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
uniphier clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
ux500 clk: ux500: sysctrl: Add a determine_rate hook 2023-06-08 18:39:30 -07:00
versatile clk: versatile: sp810: Add a determine_rate hook 2023-06-08 18:39:31 -07:00
visconti clk: visconti: Add bounds-checking coverage for struct visconti_pll_provider 2023-10-23 19:40:20 -07:00
x86 clk: x86: Convert to platform remove callback returning void 2023-03-28 19:31:45 -07:00
xilinx clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
zynq
zynqmp clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
.kunitconfig
clk-apple-nco.c
clk-asm9260.c
clk-aspeed.c Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
clk-aspeed.h
clk-ast2600.c Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
clk-axi-clkgen.c clk: axi-clkgen: Switch to determine_rate 2023-06-08 18:39:33 -07:00
clk-axm5516.c clk: axm5516: Convert to devm_platform_ioremap_resource() 2023-08-22 14:28:05 -07:00
clk-bd718x7.c
clk-bm1880.c clk: bm1880: Convert to devm_platform_ioremap_resource() 2023-08-22 14:28:11 -07:00
clk-bulk.c clk: bulk: Use dev_err_probe() helper in __clk_bulk_get() 2022-10-17 16:07:51 -07:00
clk-cdce706.c Merge branches 'clk-renesas', 'clk-determine-rate', 'clk-allwinner', 'clk-samsung' and 'clk-amlogic' into clk-next 2023-06-26 08:55:04 -07:00
clk-cdce925.c clk: cdce925: Remove redundant of_match_ptr() 2023-08-22 14:16:53 -07:00
clk-clps711x.c
clk-composite.c clk: composite: Fix handling of high clock rates 2023-06-12 17:42:10 -07:00
clk-conf.c clk: add missing of_node_put() in "assigned-clocks" property parsing 2023-03-29 13:53:28 -07:00
clk-cs2000-cp.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-devres.c clk: Fix slab-out-of-bounds error in devm_clk_release() 2023-08-22 15:25:18 -07:00
clk-divider.c
clk-en7523.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-fixed-factor.c clk: fixed-factor: Convert to platform remove callback returning void 2023-03-28 19:23:36 -07:00
clk-fixed-mmio.c Nothing looks out of the ordinary in this batch of clk driver updates. There 2023-04-29 17:29:39 -07:00
clk-fixed-rate.c clk: fixed-rate: Convert to platform remove callback returning void 2023-03-28 19:23:36 -07:00
clk-fractional-divider.c clk: Compute masks for fractional_divider clk when needed. 2023-04-05 12:09:26 -07:00
clk-fractional-divider.h
clk-fsl-flexspi.c
clk-fsl-sai.c clk: fsl-sai: Convert to devm_platform_ioremap_resource() 2023-08-22 14:28:15 -07:00
clk-gate.c
clk-gate_test.c
clk-gemini.c Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
clk-gpio.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-hi655x.c
clk-highbank.c
clk-hsdk-pll.c clk: hsdk-pll: Convert to devm_platform_ioremap_resource() 2023-08-22 14:28:20 -07:00
clk-k210.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-lan966x.c clk: lan966x: Remove unused round_rate hook 2023-06-08 18:39:25 -07:00
clk-lmk04832.c clk: lmk04832: Support using PLL1_LD as SPI readback pin 2023-08-23 15:47:35 -07:00
clk-lochnagar.c clk: lochnagar: Add a determine_rate hook 2023-06-08 18:39:27 -07:00
clk-loongson1.c clk: loongson1: Re-implement the clock driver 2023-03-21 16:34:23 -07:00
clk-loongson2.c clk: clk-loongson2: Zero init clk_init_data 2023-06-12 18:30:46 -07:00
clk-max9485.c clk: Switch i2c drivers back to use .probe() 2023-05-10 14:05:34 -07:00
clk-max77686.c
clk-milbeaut.c clk: Annotate struct clk_hw_onecell_data with __counted_by 2023-08-22 13:51:26 -07:00
clk-moxart.c
clk-multiplier.c
clk-mux.c
clk-nomadik.c clk: nomadik: correct struct name kernel-doc warning 2022-12-09 10:26:25 -08:00
clk-npcm7xx.c
clk-nspire.c
clk-palmas.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-plldig.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-pwm.c clk: pwm: Convert to platform remove callback returning void 2023-03-28 19:23:37 -07:00
clk-qoriq.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-renesas-pcie.c Merge branches 'clk-platform', 'clk-i2c', 'clk-mediatek', 'clk-i2cid' and 'clk-vc5' into clk-next 2023-06-26 08:54:19 -07:00
clk-rk808.c clk: RK808: Reduce 'struct rk808' usage 2023-05-15 16:13:56 +01:00
clk-s2mps11.c clk: s2mps11: Convert to platform remove callback returning void 2023-03-28 19:23:37 -07:00
clk-scmi.c
clk-scpi.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-si514.c clk: Switch i2c drivers back to use .probe() 2023-05-10 14:05:34 -07:00
clk-si521xx.c clk: si521xx: Switch i2c driver back to use .probe() 2023-06-12 18:16:43 -07:00
clk-si544.c clk: Switch i2c drivers back to use .probe() 2023-05-10 14:05:34 -07:00
clk-si570.c clk: Switch i2c drivers back to use .probe() 2023-05-10 14:05:34 -07:00
clk-si5341.c Merge branches 'clk-imx', 'clk-microchip', 'clk-cleanup', 'clk-bindings', 'clk-ti' and 'clk-kasprintf' into clk-next 2023-06-26 08:55:22 -07:00
clk-si5351.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-si5351.h
clk-sp7021.c clk: Annotate struct clk_hw_onecell_data with __counted_by 2023-08-22 13:51:26 -07:00
clk-sparx5.c
clk-stm32f4.c clk: stm32f4: mux: Add a determine_rate hook 2023-06-08 18:39:27 -07:00
clk-stm32h7.c clk: stm32h7: Remove an unused field in struct stm32_fractional_divider 2023-04-03 14:10:42 -07:00
clk-stm32mp1.c clk: stm32mp1: Convert to platform remove callback returning void 2023-03-28 19:23:37 -07:00
clk-tps68470.c
clk-twl6040.c
clk-versaclock3.c clk: versaclock3: Switch to use i2c_driver's probe callback 2023-08-01 13:36:49 -07:00
clk-versaclock5.c Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
clk-versaclock7.c Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00
clk-vt8500.c
clk-wm831x.c clk: wm831x: clkout: Add a determine_rate hook 2023-06-08 18:39:28 -07:00
clk-xgene.c
clk.c Merge branches 'clk-imx', 'clk-microchip', 'clk-cleanup', 'clk-bindings', 'clk-ti' and 'clk-kasprintf' into clk-next 2023-06-26 08:55:22 -07:00
clk.h
clk_test.c clk: test: Add a determine_rate hook 2023-06-08 18:39:25 -07:00
clkdev.c
Kconfig This pull request is full of clk driver changes. In fact, there aren't any 2023-08-30 19:53:39 -07:00
Makefile Merge branches 'clk-versa', 'clk-strdup', 'clk-amlogic', 'clk-allwinner' and 'clk-rockchip' into clk-next 2023-08-30 14:38:19 -07:00