All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/gma500: Remove VLA
@ 2018-04-09 21:06 ` Laura Abbott
  0 siblings, 0 replies; 5+ messages in thread
From: Laura Abbott @ 2018-04-09 21:06 UTC (permalink / raw)
  To: Patrik Jakobsson
  Cc: Laura Abbott, David Airlie, dri-devel, linux-kernel,
	kernel-hardening, Kees Cook


There's an ongoing effort to remove VLAs[1] from the kernel to eventually
turn on -Wvla. Switch to a reasonable upper bound for the VLAs in
the gma500 driver.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Laura Abbott <labbott@redhat.com>
---
This was a little hard to figure out but I think 32 should be a
comfortable upper bound based on all the structures I saw. Of course I
can't test it.
---
 drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
index 84507912be84..3d4fa9f6b94c 100644
--- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
+++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
@@ -429,13 +429,20 @@ static const char *cmd_status_names[] = {
 	"Scaling not supported"
 };
 
+#define MAX_ARG_LEN 32
+
 static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd,
 				 const void *args, int args_len)
 {
-	u8 buf[args_len*2 + 2], status;
-	struct i2c_msg msgs[args_len + 3];
+	u8 buf[MAX_ARG_LEN*2 + 2], status;
+	struct i2c_msg msgs[MAX_ARG_LEN + 3];
 	int i, ret;
 
+	if (args_len > MAX_ARG_LEN) {
+		DRM_ERROR("Need to increase arg length\n");
+		return false;
+	}
+
 	psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len);
 
 	for (i = 0; i < args_len; i++) {
-- 
2.14.3

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

* [PATCH] drm/gma500: Remove VLA
@ 2018-04-09 21:06 ` Laura Abbott
  0 siblings, 0 replies; 5+ messages in thread
From: Laura Abbott @ 2018-04-09 21:06 UTC (permalink / raw)
  To: Patrik Jakobsson
  Cc: Kees Cook, kernel-hardening, David Airlie, linux-kernel, dri-devel


There's an ongoing effort to remove VLAs[1] from the kernel to eventually
turn on -Wvla. Switch to a reasonable upper bound for the VLAs in
the gma500 driver.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Laura Abbott <labbott@redhat.com>
---
This was a little hard to figure out but I think 32 should be a
comfortable upper bound based on all the structures I saw. Of course I
can't test it.
---
 drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
index 84507912be84..3d4fa9f6b94c 100644
--- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
+++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
@@ -429,13 +429,20 @@ static const char *cmd_status_names[] = {
 	"Scaling not supported"
 };
 
+#define MAX_ARG_LEN 32
+
 static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd,
 				 const void *args, int args_len)
 {
-	u8 buf[args_len*2 + 2], status;
-	struct i2c_msg msgs[args_len + 3];
+	u8 buf[MAX_ARG_LEN*2 + 2], status;
+	struct i2c_msg msgs[MAX_ARG_LEN + 3];
 	int i, ret;
 
+	if (args_len > MAX_ARG_LEN) {
+		DRM_ERROR("Need to increase arg length\n");
+		return false;
+	}
+
 	psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len);
 
 	for (i = 0; i < args_len; i++) {
-- 
2.14.3

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/gma500: Remove VLA
  2018-04-09 21:06 ` Laura Abbott
  (?)
@ 2018-05-18 17:58 ` Kees Cook
  2018-05-23  8:44     ` Daniel Vetter
  -1 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2018-05-18 17:58 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Laura Abbott, Patrik Jakobsson, David Airlie,
	Maling list - DRI developers, LKML, Kernel Hardening

On Mon, Apr 9, 2018 at 2:06 PM, Laura Abbott <labbott@redhat.com> wrote:
>
> There's an ongoing effort to remove VLAs[1] from the kernel to eventually
> turn on -Wvla. Switch to a reasonable upper bound for the VLAs in
> the gma500 driver.
>
> [1] https://lkml.org/lkml/2018/3/7/621
>
> Signed-off-by: Laura Abbott <labbott@redhat.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

Daniel, can this go via you, or what's the best path for this patch?

Thanks!

-Kees

> ---
> This was a little hard to figure out but I think 32 should be a
> comfortable upper bound based on all the structures I saw. Of course I
> can't test it.
> ---
>  drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> index 84507912be84..3d4fa9f6b94c 100644
> --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> @@ -429,13 +429,20 @@ static const char *cmd_status_names[] = {
>         "Scaling not supported"
>  };
>
> +#define MAX_ARG_LEN 32
> +
>  static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd,
>                                  const void *args, int args_len)
>  {
> -       u8 buf[args_len*2 + 2], status;
> -       struct i2c_msg msgs[args_len + 3];
> +       u8 buf[MAX_ARG_LEN*2 + 2], status;
> +       struct i2c_msg msgs[MAX_ARG_LEN + 3];
>         int i, ret;
>
> +       if (args_len > MAX_ARG_LEN) {
> +               DRM_ERROR("Need to increase arg length\n");
> +               return false;
> +       }
> +
>         psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len);
>
>         for (i = 0; i < args_len; i++) {
> --
> 2.14.3
>



-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] drm/gma500: Remove VLA
  2018-05-18 17:58 ` Kees Cook
@ 2018-05-23  8:44     ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2018-05-23  8:44 UTC (permalink / raw)
  To: Kees Cook
  Cc: Daniel Vetter, Laura Abbott, Patrik Jakobsson, David Airlie,
	Maling list - DRI developers, LKML, Kernel Hardening

On Fri, May 18, 2018 at 10:58:40AM -0700, Kees Cook wrote:
> On Mon, Apr 9, 2018 at 2:06 PM, Laura Abbott <labbott@redhat.com> wrote:
> >
> > There's an ongoing effort to remove VLAs[1] from the kernel to eventually
> > turn on -Wvla. Switch to a reasonable upper bound for the VLAs in
> > the gma500 driver.
> >
> > [1] https://lkml.org/lkml/2018/3/7/621
> >
> > Signed-off-by: Laura Abbott <labbott@redhat.com>
> 
> Reviewed-by: Kees Cook <keescook@chromium.org>
> 
> Daniel, can this go via you, or what's the best path for this patch?

Applied to drm-misc-next for 4.19, thanks.
-Daniel

> 
> Thanks!
> 
> -Kees
> 
> > ---
> > This was a little hard to figure out but I think 32 should be a
> > comfortable upper bound based on all the structures I saw. Of course I
> > can't test it.
> > ---
> >  drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > index 84507912be84..3d4fa9f6b94c 100644
> > --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > @@ -429,13 +429,20 @@ static const char *cmd_status_names[] = {
> >         "Scaling not supported"
> >  };
> >
> > +#define MAX_ARG_LEN 32
> > +
> >  static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd,
> >                                  const void *args, int args_len)
> >  {
> > -       u8 buf[args_len*2 + 2], status;
> > -       struct i2c_msg msgs[args_len + 3];
> > +       u8 buf[MAX_ARG_LEN*2 + 2], status;
> > +       struct i2c_msg msgs[MAX_ARG_LEN + 3];
> >         int i, ret;
> >
> > +       if (args_len > MAX_ARG_LEN) {
> > +               DRM_ERROR("Need to increase arg length\n");
> > +               return false;
> > +       }
> > +
> >         psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len);
> >
> >         for (i = 0; i < args_len; i++) {
> > --
> > 2.14.3
> >
> 
> 
> 
> -- 
> Kees Cook
> Pixel Security

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [PATCH] drm/gma500: Remove VLA
@ 2018-05-23  8:44     ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2018-05-23  8:44 UTC (permalink / raw)
  To: Kees Cook
  Cc: Kernel Hardening, David Airlie, Daniel Vetter, LKML,
	Maling list - DRI developers

On Fri, May 18, 2018 at 10:58:40AM -0700, Kees Cook wrote:
> On Mon, Apr 9, 2018 at 2:06 PM, Laura Abbott <labbott@redhat.com> wrote:
> >
> > There's an ongoing effort to remove VLAs[1] from the kernel to eventually
> > turn on -Wvla. Switch to a reasonable upper bound for the VLAs in
> > the gma500 driver.
> >
> > [1] https://lkml.org/lkml/2018/3/7/621
> >
> > Signed-off-by: Laura Abbott <labbott@redhat.com>
> 
> Reviewed-by: Kees Cook <keescook@chromium.org>
> 
> Daniel, can this go via you, or what's the best path for this patch?

Applied to drm-misc-next for 4.19, thanks.
-Daniel

> 
> Thanks!
> 
> -Kees
> 
> > ---
> > This was a little hard to figure out but I think 32 should be a
> > comfortable upper bound based on all the structures I saw. Of course I
> > can't test it.
> > ---
> >  drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > index 84507912be84..3d4fa9f6b94c 100644
> > --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > @@ -429,13 +429,20 @@ static const char *cmd_status_names[] = {
> >         "Scaling not supported"
> >  };
> >
> > +#define MAX_ARG_LEN 32
> > +
> >  static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd,
> >                                  const void *args, int args_len)
> >  {
> > -       u8 buf[args_len*2 + 2], status;
> > -       struct i2c_msg msgs[args_len + 3];
> > +       u8 buf[MAX_ARG_LEN*2 + 2], status;
> > +       struct i2c_msg msgs[MAX_ARG_LEN + 3];
> >         int i, ret;
> >
> > +       if (args_len > MAX_ARG_LEN) {
> > +               DRM_ERROR("Need to increase arg length\n");
> > +               return false;
> > +       }
> > +
> >         psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len);
> >
> >         for (i = 0; i < args_len; i++) {
> > --
> > 2.14.3
> >
> 
> 
> 
> -- 
> Kees Cook
> Pixel Security

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2018-05-23  8:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 21:06 [PATCH] drm/gma500: Remove VLA Laura Abbott
2018-04-09 21:06 ` Laura Abbott
2018-05-18 17:58 ` Kees Cook
2018-05-23  8:44   ` Daniel Vetter
2018-05-23  8:44     ` Daniel Vetter

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.