All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Himanshu Jha <himanshujha199640@gmail.com>
Cc: jic23@kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: Re: [PATCH] iio: potentiometer: ds1803: Remove VLA usage
Date: Thu, 8 Mar 2018 11:39:15 -0800	[thread overview]
Message-ID: <CAGXu5jJzLczSzfJtWbhTUqAYXRG_-zKf2x8cz8jrAxu+XjkYdQ@mail.gmail.com> (raw)
In-Reply-To: <1520534733-1743-1-git-send-email-himanshujha199640@gmail.com>

On Thu, Mar 8, 2018 at 10:45 AM, Himanshu Jha
<himanshujha199640@gmail.com> wrote:
> In preparation to enabling -Wvla, remove VLA usage and replace it
> with fixed a fixed length array and therefore, prevent potential
> stack overflow attacks.
>
> Fixed as a part of the discussion to remove all VLAs from the kernel:
> https://lkml.org/lkml/2018/3/7/621
>
> Cc: keescook@chromium.org
> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
> ---
>  drivers/iio/potentiometer/ds1803.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c
> index 9b0ff4a..6bf12c9 100644
> --- a/drivers/iio/potentiometer/ds1803.c
> +++ b/drivers/iio/potentiometer/ds1803.c
> @@ -64,7 +64,7 @@ static int ds1803_read_raw(struct iio_dev *indio_dev,
>         struct ds1803_data *data = iio_priv(indio_dev);
>         int pot = chan->channel;
>         int ret;
> -       u8 result[indio_dev->num_channels];
> +       u8 result[ARRAY_SIZE(ds1803_channels)];

It seems like num_channels is always ARRAY_SIZE(ds1803_channels).
Could the entire field be dropped?

-Kees

>
>         switch (mask) {
>         case IIO_CHAN_INFO_RAW:
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security

  reply	other threads:[~2018-03-08 19:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 18:45 [PATCH] iio: potentiometer: ds1803: Remove VLA usage Himanshu Jha
2018-03-08 19:39 ` Kees Cook [this message]
2018-03-09 11:05   ` Himanshu Jha
2018-03-10 15:04     ` Jonathan Cameron
2018-03-13 15:23 [PATCH] iio: potentiometer: ds1803: remove " Gustavo A. R. Silva
2018-03-13 16:24 ` Himanshu Jha
2018-03-13 16:31   ` Gustavo A. R. Silva
2018-03-13 16:59     ` Himanshu Jha
2018-03-13 17:05       ` Gustavo A. R. Silva
2018-03-13 17:07       ` Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGXu5jJzLczSzfJtWbhTUqAYXRG_-zKf2x8cz8jrAxu+XjkYdQ@mail.gmail.com \
    --to=keescook@chromium.org \
    --cc=garsilva@embeddedor.com \
    --cc=himanshujha199640@gmail.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.