Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1478472

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()
Date 2016-09-07 18:30 +0200
Message-ID <seNTB-25W-45@gated-at.bofh.it> (permalink)
References (2 earlier) <seFW2-5g7-9@gated-at.bofh.it> <seIqS-6Zc-17@gated-at.bofh.it> <seJdg-7vS-13@gated-at.bofh.it> <seJdg-7vS-27@gated-at.bofh.it> <seJwD-7Cz-41@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Sep 7, 2016 at 4:45 AM, SF Markus Elfring
<elfring@users.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@Sonne:~/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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-04 22:30 +0200
  Re: [PATCH] x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() Kees Cook <keescook@chromium.org> - 2016-09-07 00:00 +0200
    Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-07 10:00 +0200
      Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-07 12:40 +0200
        Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-07 13:30 +0200
          Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-07 13:30 +0200
            Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-07 13:50 +0200
              Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() Kees Cook <keescook@chromium.org> - 2016-09-07 18:30 +0200
                Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() Joe Perches <joe@perches.com> - 2016-09-07 18:40 +0200
                Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() Kees Cook <keescook@chromium.org> - 2016-09-07 19:10 +0200
                Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-07 19:00 +0200

csiph-web