Skip to contentSkip to conversation

bus: imx-weim: Remove VLA usage

PATCH In review Kees Cook 4 participants 5 messages Jun 29, 2018 – Jul 3, 2018 Arm i.MX and Layerscape

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 bus: imx-weim: Remove VLA usage

In the quest to remove all stack VLA usage from the kernel[1], this switches to using a maximum size and adds a sanity check.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Cc Maxime Ripard <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Rob Herring <[email protected]>
---
 drivers/bus/imx-weim.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/bus/imx-weim.c +6 -1
index 3d56ebcda720..6a94aa6a22c2 100644
@@ -45,6 +45,8 @@ static const struct imx_weim_devtype imx51_weim_devtype = {
 	.cs_stride	= 0x18,
 };
 
+#define MAX_CS_REGS_COUNT	6
+
 static const struct of_device_id weim_id_table[] = {
 	/* i.MX1/21 */
 	{ .compatible = "fsl,imx1-weim", .data = &imx1_weim_devtype, },
@@ -112,9 +114,12 @@ static int __init imx_weim_gpr_setup(struct platform_device *pdev)
 static int __init weim_timing_setup(struct device_node *np, void __iomem *base,
 				    const struct imx_weim_devtype *devtype)
 {
-	u32 cs_idx, value[devtype->cs_regs_count];
+	u32 cs_idx, value[MAX_CS_REGS_COUNT];
 	int i, ret;
 
+	if (WARN_ON(devtype->cs_regs_count > MAX_CS_REGS_COUNT))
+		return -EINVAL;
+
 	/* get the CS index from this child node's "reg" property. */
 	ret = of_property_read_u32(np, "reg", &cs_idx);
 	if (ret)
Signature · 6 lines
2.17.1


-- 
Kees Cook
Pixel Security
#1 lore raw
Quoted 10 lines · Kees Cook

In the quest to remove all stack VLA usage from the kernel[1], this switches to using a maximum size and adds a sanity check.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Cc Maxime Ripard <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Rob Herring <[email protected]>

Not sure how you came up with the CC list, but you should probably have some i.MX folks CC'ed.

Rob

author
#2 lore raw
Quoted 7 lines · Rob Herring
Quoted 6 lines · Kees Cook

In the quest to remove all stack VLA usage from the kernel[1], this switches to using a maximum size and adds a sanity check.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Quoted 7 lines
Quoted 4 lines
Cc Maxime Ripard <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Rob Herring <[email protected]>

Not sure how you came up with the CC list, but you should probably have some i.MX folks CC'ed.

Automation for the lose, apparently. :) Looks like maybe the MAINTAINER entry for IMX needs a drivers/bus/imx* line added. :)

Adding more CCs...

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
Acked-by
#3 lore raw
Quoted 13 lines · Kees Cook
Quoted 12 lines · Rob Herring
Quoted 10 lines · Kees Cook

In the quest to remove all stack VLA usage from the kernel[1], this switches to using a maximum size and adds a sanity check.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Cc Maxime Ripard <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Rob Herring <[email protected]>
Quoted 7 lines
Quoted 2 lines

Not sure how you came up with the CC list, but you should probably have some i.MX folks CC'ed.

Automation for the lose, apparently. :) Looks like maybe the MAINTAINER entry for IMX needs a drivers/bus/imx* line added. :)

Adding more CCs...

Reviewed-by on v1 1/1
#4 lore raw
In reply to Kees Cook
Quoted 9 lines · Kees Cook

In the quest to remove all stack VLA usage from the kernel[1], this switches to using a maximum size and adds a sanity check.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Cc Maxime Ripard <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Rob Herring <[email protected]>