LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Kees Cook <keescook@chromium.org>
Cc: Kyle Spiers <ksspiers@google.com>,
	David Miller <davem@davemloft.net>,
	ray.jui@broadcom.com, linux-crypto <linux-crypto@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-raid <linux-raid@vger.kernel.org>,
	vkoul@kernel.org
Subject: Re: [PATCH v2] async_pq: Remove VLA usage
Date: Wed, 30 May 2018 15:04:02 -0700	[thread overview]
Message-ID: <CAPcyv4j9AoRtjpLfHX=gjgv35gNtb5fKt3rFaGA4ZPkPg1GfmQ@mail.gmail.com> (raw)
In-Reply-To: <CAGXu5jL5hzArDhKJzG+jd7wQVJfXGPT1tUys-FzNOS6MTE-jFA@mail.gmail.com>

On Wed, May 30, 2018 at 2:33 PM, Kees Cook <keescook@chromium.org> wrote:
> On Tue, May 29, 2018 at 3:40 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>> [ add Vinod's korg address ]
>>
>> On Tue, May 29, 2018 at 3:37 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>>> [ adding linux-raid ]
>>>
>>> Apologies for the delay, the recent ping from Kees made me take a closer look.
>>>
>>> On Sat, May 5, 2018 at 12:58 AM, Kyle Spiers <ksspiers@google.com> wrote:
>>>> In the quest to remove VLAs from the kernel[1], this moves the
>>>> allocation of coefs and blocks from the stack to being kmalloc()ed.
>>>>
>>>> [1] https://lkml.org/lkml/2018/3/7/621
>>>>
>>>> Signed-off-by: Kyle Spiers <ksspiers@google.com>
>>>> ---
>>>> Forgot to add slab.h
>>>> ---
>>>>  crypto/async_tx/async_pq.c  | 18 ++++++++++++++----
>>>>  crypto/async_tx/raid6test.c |  9 ++++++++-
>>>>  2 files changed, 22 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/crypto/async_tx/async_pq.c b/crypto/async_tx/async_pq.c
>>>> index 56bd612927ab..af1912313a23 100644
>>>> --- a/crypto/async_tx/async_pq.c
>>>> +++ b/crypto/async_tx/async_pq.c
>>>> @@ -194,9 +194,9 @@ async_gen_syndrome(struct page **blocks, unsigned int offset, int disks,
>>>>             (src_cnt <= dma_maxpq(device, 0) ||
>>>>              dma_maxpq(device, DMA_PREP_CONTINUE) > 0) &&
>>>>             is_dma_pq_aligned(device, offset, 0, len)) {
>>>> -               struct dma_async_tx_descriptor *tx;
>>>> +               struct dma_async_tx_descriptor *tx = NULL;
>>>>                 enum dma_ctrl_flags dma_flags = 0;
>>>> -               unsigned char coefs[src_cnt];
>>>> +               unsigned char *coefs;
>>> At a minimum this needs to be GFP_NOIO since raid may be in the
>>> page-reclaim path.
>>>
>>> However, I think it may be better to allocate this with the rest of
>>> the stripe resources and pass it in as a scratch buffer. See the usage
>>> / implementation of scribble_alloc() in drivers/md/raid5.c.
>
> Given this:
>
>         int src_cnt = disks - 2;
> ...
>         BUG_ON(disks > 255 || ...)
>
> what about just making something like:
>
> #define MAX_DISKS 255
> ...
>         int src_cnt = disks - 2;
> ...
>         BUG_ON(disks > MAX_DISKS || ...)
> ...
>                  unsigned char coefs[MAX_DISKS];
>
> ?

Yeah, we were already potentially suffering a value that large on the
stack in a max config case anyway with the VLA. Looks ok to me.

      reply	other threads:[~2018-05-30 22:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-05  7:58 Kyle Spiers
2018-05-10 20:57 ` Kees Cook
2018-05-29 22:24   ` Kees Cook
2018-05-29 22:37 ` Dan Williams
2018-05-29 22:40   ` Dan Williams
2018-05-30 21:33     ` Kees Cook
2018-05-30 22:04       ` Dan Williams [this message]

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='CAPcyv4j9AoRtjpLfHX=gjgv35gNtb5fKt3rFaGA4ZPkPg1GfmQ@mail.gmail.com' \
    --to=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=keescook@chromium.org \
    --cc=ksspiers@google.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=ray.jui@broadcom.com \
    --cc=vkoul@kernel.org \
    --subject='Re: [PATCH v2] async_pq: Remove VLA usage' \
    /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

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).