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, 7 Sep 2016 09:23:08 -0700
From:   Kees Cook <keescook@...omium.org>
To:     SF Markus Elfring <elfring@...rs.sourceforge.net>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Ingo Molnar <mingo@...hat.com>,
        "x86@...nel.org" <x86@...nel.org>, Dave Young <dyoung@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Matt Fleming <matt.fleming@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org,
        Julia Lawall <julia.lawall@...6.fr>
Subject: Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

On Wed, Sep 7, 2016 at 4:45 AM, SF Markus Elfring
<elfring@...rs.sourceforge.net> wrote:
>>> Would the following script (for the semantic patch language)
>>> be useful enough for further development considerations?
>>>
>>> usage_of_kmalloc_array1-excerpt2.cocci:
>>> @replacement2@
>>> expression count, pointer, target;
>>> @@
>>>  target =
>>> -         kmalloc(sizeof(*pointer) * (count)
>>> +         kmalloc_array(count, sizeof(*pointer)
>>>                         , ...);
>>
>> Why don't you include the _exact_ script that you run?
>
> I showed only the "excerpt" above because of the current situation
> that this single SmPL rule triggered the software change
> which I suggested for the referenced source file.
>
> How do you think about to try a command out like the following
> also in your development (or test) environment?
>
> elfring@...ne:~/Projekte/Linux/next-patched> spatch.opt ~/Projekte/Coccinelle/janitor/usage_of_kmalloc_array1-excerpt2.cocci arch/x86/kernel/ksysfs.c

Fixing these kmalloc calls would be a nice thing to clean up
everywhere. Since it is a mistake people may continue to make, I think
it would make sense to add a coccinelle script that can do this to the
existing coccinelle scripts in the kernel if one to do it does not
already exist. That way, it will be part of the coccinelle checking
that is automatically run on the kernel regularly.

-Kees

-- 
Kees Cook
Nexus Security

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ