linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: imx-weim: Remove VLA usage
@ 2018-06-29 18:52 Kees Cook
  2018-06-29 19:45 ` Rob Herring
  2018-06-29 21:28 ` Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Kees Cook @ 2018-06-29 18:52 UTC (permalink / raw)
  To: Maxime Ripard; +Cc: Arnd Bergmann, Rob Herring, linux-kernel

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 <maxime.ripard@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/bus/imx-weim.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 3d56ebcda720..6a94aa6a22c2 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -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)
-- 
2.17.1


-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] bus: imx-weim: Remove VLA usage
  2018-06-29 18:52 [PATCH] bus: imx-weim: Remove VLA usage Kees Cook
@ 2018-06-29 19:45 ` Rob Herring
  2018-06-29 20:02   ` Kees Cook
  2018-06-29 21:28 ` Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: Rob Herring @ 2018-06-29 19:45 UTC (permalink / raw)
  To: Kees Cook; +Cc: Maxime Ripard, Arnd Bergmann, linux-kernel

On Fri, Jun 29, 2018 at 12:52 PM Kees Cook <keescook@chromium.org> wrote:
>
> 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 <maxime.ripard@free-electrons.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Rob Herring <robh@kernel.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>

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

Rob

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

* Re: [PATCH] bus: imx-weim: Remove VLA usage
  2018-06-29 19:45 ` Rob Herring
@ 2018-06-29 20:02   ` Kees Cook
  2018-07-03  6:30     ` Shawn Guo
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2018-06-29 20:02 UTC (permalink / raw)
  To: Rob Herring
  Cc: Maxime Ripard, Arnd Bergmann, linux-kernel, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team

On Fri, Jun 29, 2018 at 12:45 PM, Rob Herring <robh@kernel.org> wrote:
> On Fri, Jun 29, 2018 at 12:52 PM Kees Cook <keescook@chromium.org> wrote:
>>
>> 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 <maxime.ripard@free-electrons.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Rob Herring <robh@kernel.org>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> 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

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] bus: imx-weim: Remove VLA usage
  2018-06-29 18:52 [PATCH] bus: imx-weim: Remove VLA usage Kees Cook
  2018-06-29 19:45 ` Rob Herring
@ 2018-06-29 21:28 ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2018-06-29 21:28 UTC (permalink / raw)
  To: Kees Cook; +Cc: Maxime Ripard, Rob Herring, Linux Kernel Mailing List

On Fri, Jun 29, 2018 at 8:52 PM, Kees Cook <keescook@chromium.org> wrote:
> 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 <maxime.ripard@free-electrons.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Rob Herring <robh@kernel.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH] bus: imx-weim: Remove VLA usage
  2018-06-29 20:02   ` Kees Cook
@ 2018-07-03  6:30     ` Shawn Guo
  0 siblings, 0 replies; 5+ messages in thread
From: Shawn Guo @ 2018-07-03  6:30 UTC (permalink / raw)
  To: Kees Cook
  Cc: Rob Herring, Maxime Ripard, Arnd Bergmann, linux-kernel,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team

On Fri, Jun 29, 2018 at 01:02:36PM -0700, Kees Cook wrote:
> On Fri, Jun 29, 2018 at 12:45 PM, Rob Herring <robh@kernel.org> wrote:
> > On Fri, Jun 29, 2018 at 12:52 PM Kees Cook <keescook@chromium.org> wrote:
> >>
> >> 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 <maxime.ripard@free-electrons.com>
> >> Cc: Arnd Bergmann <arnd@arndb.de>
> >> Cc: Rob Herring <robh@kernel.org>
> >> Signed-off-by: Kees Cook <keescook@chromium.org>
> >
> > 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...

Acked-by: Shawn Guo <shawnguo@kernel.org>

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

end of thread, other threads:[~2018-07-03  6:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 18:52 [PATCH] bus: imx-weim: Remove VLA usage Kees Cook
2018-06-29 19:45 ` Rob Herring
2018-06-29 20:02   ` Kees Cook
2018-07-03  6:30     ` Shawn Guo
2018-06-29 21:28 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).