lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 4 Apr 2018 11:31:41 -0700
From:   Laura Abbott <labbott@...hat.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Kees Cook <keescook@...omium.org>,
        Lukas Wunner <lukas@...ner.de>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        kernel-hardening@...ts.openwall.com,
        Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: Re: [PATCHv3] gpio: Remove VLA from gpiolib

On 03/30/2018 07:33 AM, Andy Shevchenko wrote:
> On Wed, Mar 28, 2018 at 9:18 PM, Laura Abbott <labbott@...hat.com> wrote:
>> The new challenge is to remove VLAs from the kernel
>> (see https://lkml.org/lkml/2018/3/7/621) to eventually
>> turn on -Wvla.
>>
>> Using a kmalloc array is the easy way to fix this but kmalloc is still
>> more expensive than stack allocation. Introduce a fast path with a
>> fixed size stack array to cover most chip with gpios below some fixed
>> amount. The slow path dynamically allocates an array to cover those
>> chips with a large number of gpios.
> 
>> +               ret = gpiod_set_array_value_complex(false,
>>                                                true,
>>                                                lh->numdescs,
>>                                                lh->descs,
>>                                                vals);
>> +               if (ret)
>> +                       return ret;
>> +
>>                  return 0;
> 
> Can't we
> 
> return gpiod_set_array_value_complex(); ?
> 
> 

Yeah I'll clean that up for v4.

>> +                       slowpath = kcalloc(2 * BITS_TO_LONGS(chip->ngpio),
>> +                                          sizeof(*slowpath),
>> +                                          can_sleep ? GFP_KERNEL : GFP_ATOMIC);
> 
> 
>> +                       if (slowpath)
>> +                               kfree(slowpath);
> 
>> +               if (slowpath)
>> +                       kfree(slowpath);
> 
> Since slowpath is a pointer, conditionals above are redundant.
> 
>> +                       slowpath = kcalloc(2 * BITS_TO_LONGS(chip->ngpio),
>> +                                          sizeof(*slowpath),
>> +                                          can_sleep ? GFP_KERNEL : GFP_ATOMIC);
> 
>> +               if (slowpath)
>> +                       kfree(slowpath);
> 
> Ditto.
> 

This was caught by a coccinelle script via 0-day but I think the request
was to not do it. I'll add a comment explaining why we are going against
style.

Thanks,
Laura

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ