Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants

"Mohammed Billoo" <[email protected]> Thu, 13 Aug 2020 10:45:37 -0400
Newsgroups tech.elisa.lists.linux-safety
Message-ID <CALkjhPpmHusUTaY1dbohM_Fc7UrGSXUav=evqg+6rauBdaVemA@mail.gmail.com>
I also had a few more questions regarding the overall format:
1. Is the header format in the semantic patch acceptable (i.e. referencing
the CWE that this particular semantic patch aims to address)?
2. Should we create a separate directory for ELISA within coccinelle?

Thanks
Mohammed

On Thu, Aug 13, 2020 at 10:42 AM Mohammed Billoo via lists.elisa.tech
<[email protected]> wrote:

> Shuah,
>
> Apologies for the spam. I didn't format the initial correctly and needed
> two more tries to get it right (according to the kernel
> standard/best-practice). I can resubmit this patch.
>
> Thanks
>
> On Thu, Aug 13, 2020 at 10:39 AM Shuah Khan <[email protected]>
> wrote:
>
>> Hi Mohammed,
>>
>> Thanks for your patch.
>>
>> On 8/12/20 5:43 PM, Mohammed Billoo wrote:
>> > This semantic patch looks for variables that are initialized to
>> > constants, arrays that are both declared and indexed with constants.
>> > A false positive will occur  when a variable is initialized to 0, which
>> > must happen for auto variables. This will be resolved in a future patch.
>> >
>> > The patch was tested against the following snippet:
>> >
>> > int main()
>> > {
>> >      int iarr[54]; /* instance 1 */
>> >      int j = 0;    /* instance 2 */
>> >      int i = 1;    /* instance 3 */
>> >      iarr[0] = 3;  /* instance 4 */
>> >      return 0;
>> > }
>> >
>> > and it correctly identified instances 1, 3, and 4. It incorrectly
>> > identified instance 2, which will be addressed in a future patch.
>>
>> Please include the output from the tool that corresponds to your
>> changes to the script in the commit log on a kernel file.
>>
>> Also I see 3 patches with incremental changes to the script. Please
>> make this a patch series which will make it easier for reviewers.
>>
>> thanks,
>> -- Shuah
>>
>
>
> --
> Mohammed A Billoo
> Founder
> MAB Labs, LLC
> www.mab-labs.com
> 201-338-2022
> 
>
>

-- 
Mohammed A Billoo
Founder
MAB Labs, LLC
www.mab-labs.com
201-338-2022