linux-safety.lists.elisa.tech archive mirror
 help / color / mirror / Atom feed
* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
@ 2020-08-13 15:16 Lukas Bulwahn
  2020-08-13 15:23 ` Mohammed Billoo
  0 siblings, 1 reply; 10+ messages in thread
From: Lukas Bulwahn @ 2020-08-13 15:16 UTC (permalink / raw)
  To: mab; +Cc: skhan, linux-safety

To your questions, here is my opinion...

1. Is the header format in the semantic patch acceptable (i.e. referencing the CWE that this particular semantic patch aims to address)?

Actually, I think we should that for the existing rules as well.

I was thinking of the following format:

# Addresses: CWE-414 ("Missing Lock Check")

or

# Contributes-to: Missing Lock Check [CWE-414]

I think it is good discussion to have with Julia Lawall, Dan Carpenter, Luc Van Oostenryck, Joe Perches, etc. to see how they would want to maintain such information within their tools.


2. Should we create a separate directory for ELISA within coccinelle?

No, we do not structure according to the contributor, then the kernel architecture would be "linus directory", "andrew directory", "shuah directory", etc.

I would suggest that we could roughly structure according the existing structure for coccinelle and the CWE structure.


Lukas

P.S.: We need to set groups.io not to generate HTML emails on responses etc. when we want to engage with the kernel community. Let us check if we get that set up.
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
  2020-08-13 15:16 [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants Lukas Bulwahn
@ 2020-08-13 15:23 ` Mohammed Billoo
  2020-08-13 15:33   ` Lukas Bulwahn
  0 siblings, 1 reply; 10+ messages in thread
From: Mohammed Billoo @ 2020-08-13 15:23 UTC (permalink / raw)
  To: Lukas Bulwahn; +Cc: Shuah Khan, linux-safety

[-- Attachment #1: Type: text/plain, Size: 1814 bytes --]

With regards to the directory name, it wasn't meant to be for this specific
group, but a sensible category to put these patches in. In my experience,
misc becomes a catch-all for everything else, promotes laziness, and things
end up being a mess. Does it make sense to create another directory that
contains patches that are specific to catching CWEs (e.g. a directory
called "safety" or "safety-critical") that don't obviously fall into the
other non-misc directories?

On Thu, Aug 13, 2020 at 11:16 AM <Lukas.Bulwahn@bmw.de> wrote:

> To your questions, here is my opinion...
>
> 1. Is the header format in the semantic patch acceptable (i.e. referencing
> the CWE that this particular semantic patch aims to address)?
>
> Actually, I think we should that for the existing rules as well.
>
> I was thinking of the following format:
>
> # Addresses: CWE-414 ("Missing Lock Check")
>
> or
>
> # Contributes-to: Missing Lock Check [CWE-414]
>
> I think it is good discussion to have with Julia Lawall, Dan Carpenter,
> Luc Van Oostenryck, Joe Perches, etc. to see how they would want to
> maintain such information within their tools.
>
>
> 2. Should we create a separate directory for ELISA within coccinelle?
>
> No, we do not structure according to the contributor, then the kernel
> architecture would be "linus directory", "andrew directory", "shuah
> directory", etc.
>
> I would suggest that we could roughly structure according the existing
> structure for coccinelle and the CWE structure.
>
>
> Lukas
>
> P.S.: We need to set groups.io not to generate HTML emails on responses
> etc. when we want to engage with the kernel community. Let us check if we
> get that set up.
>
>

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

[-- Attachment #2: Type: text/html, Size: 2471 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
  2020-08-13 15:23 ` Mohammed Billoo
@ 2020-08-13 15:33   ` Lukas Bulwahn
  2020-08-13 15:41     ` Sudip Mukherjee
  0 siblings, 1 reply; 10+ messages in thread
From: Lukas Bulwahn @ 2020-08-13 15:33 UTC (permalink / raw)
  To: mab; +Cc: skhan, linux-safety

[-- Attachment #1: Type: text/plain, Size: 2512 bytes --]

Sorry for top posting.

No, safety is CERTAINLY NOT a category. Security maybe, but even better would be a category like “information leaks” and a subset “kernel-internal information leaks” for your specific coccinelle rule addressing CWE-547.

For me, for now, misc is okay, but if we want to restructure and clean-up, we should come up with a complete picture that fits for all.

Lukas

Von: Mohammed Billoo <mab@mab-labs.com>
Gesendet: Donnerstag, 13. August 2020 17:24
An: Bulwahn Lukas, JC-20 <Lukas.Bulwahn@bmw.de>
Cc: Shuah Khan <skhan@linuxfoundation.org>; linux-safety@lists.elisa.tech
Betreff: Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants

With regards to the directory name, it wasn't meant to be for this specific group, but a sensible category to put these patches in. In my experience, misc becomes a catch-all for everything else, promotes laziness, and things end up being a mess. Does it make sense to create another directory that contains patches that are specific to catching CWEs (e.g. a directory called "safety" or "safety-critical") that don't obviously fall into the other non-misc directories?

On Thu, Aug 13, 2020 at 11:16 AM <Lukas.Bulwahn@bmw.de<mailto:Lukas.Bulwahn@bmw.de>> wrote:
To your questions, here is my opinion...

1. Is the header format in the semantic patch acceptable (i.e. referencing the CWE that this particular semantic patch aims to address)?

Actually, I think we should that for the existing rules as well.

I was thinking of the following format:

# Addresses: CWE-414 ("Missing Lock Check")

or

# Contributes-to: Missing Lock Check [CWE-414]

I think it is good discussion to have with Julia Lawall, Dan Carpenter, Luc Van Oostenryck, Joe Perches, etc. to see how they would want to maintain such information within their tools.


2. Should we create a separate directory for ELISA within coccinelle?

No, we do not structure according to the contributor, then the kernel architecture would be "linus directory", "andrew directory", "shuah directory", etc.

I would suggest that we could roughly structure according the existing structure for coccinelle and the CWE structure.


Lukas

P.S.: We need to set groups.io<http://groups.io> not to generate HTML emails on responses etc. when we want to engage with the kernel community. Let us check if we get that set up.


--
Mohammed A Billoo
Founder
MAB Labs, LLC
www.mab-labs.com<http://www.mab-labs.com>
201-338-2022

[-- Attachment #2: Type: text/html, Size: 6133 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
  2020-08-13 15:33   ` Lukas Bulwahn
@ 2020-08-13 15:41     ` Sudip Mukherjee
  2020-08-13 17:02       ` Shuah Khan
       [not found]       ` <162AE2925F9D984B.16363@lists.elisa.tech>
  0 siblings, 2 replies; 10+ messages in thread
From: Sudip Mukherjee @ 2020-08-13 15:41 UTC (permalink / raw)
  To: mab; +Cc: Lukas Bulwahn, skhan, linux-safety



On 13/08/2020 16:33, Lukas Bulwahn wrote:
> Sorry for top posting.
> 
>  
> 
> No, safety is CERTAINLY NOT a category. Security maybe, but even better
> would be a category like “information leaks” and a subset
> “kernel-internal information leaks” for your specific coccinelle rule
> addressing CWE-547.
> 
>  
> 
> For me, for now, misc is okay, but if we want to restructure and
> clean-up, we should come up with a complete picture that fits for all.

imho, misc is ok for this one, but when you actually make a cocci script
for CWE-414 ("Missing Lock Check"), that should be going to
scripts/coccinelle/locks/



-- 
Regards
Sudip

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
  2020-08-13 15:41     ` Sudip Mukherjee
@ 2020-08-13 17:02       ` Shuah Khan
       [not found]       ` <162AE2925F9D984B.16363@lists.elisa.tech>
  1 sibling, 0 replies; 10+ messages in thread
From: Shuah Khan @ 2020-08-13 17:02 UTC (permalink / raw)
  To: Sudip Mukherjee, mab; +Cc: Lukas Bulwahn, linux-safety

On 8/13/20 9:41 AM, Sudip Mukherjee wrote:
> 
> 
> On 13/08/2020 16:33, Lukas Bulwahn wrote:
>> Sorry for top posting.
>>
>>   
>>
>> No, safety is CERTAINLY NOT a category. Security maybe, but even better
>> would be a category like “information leaks” and a subset
>> “kernel-internal information leaks” for your specific coccinelle rule
>> addressing CWE-547.
>>

+1

>>   
>>
>> For me, for now, misc is okay, but if we want to restructure and
>> clean-up, we should come up with a complete picture that fits for all.
> 
> imho, misc is ok for this one, but when you actually make a cocci script
> for CWE-414 ("Missing Lock Check"), that should be going to
> scripts/coccinelle/locks/
> 

+1
Agree with Lukas and Sudip on directory - safety isn't appropriate here.

You can find a suitable place: current coverage areas under
scripts/coccinelle are

api  free  iterators  locks  misc  null  tests

Let's try to map new scripts to these categories or create a new
category when one doesn't exist.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
       [not found]       ` <162AE2925F9D984B.16363@lists.elisa.tech>
@ 2020-08-13 19:43         ` Shuah Khan
  0 siblings, 0 replies; 10+ messages in thread
From: Shuah Khan @ 2020-08-13 19:43 UTC (permalink / raw)
  To: Sudip Mukherjee, mab; +Cc: Lukas Bulwahn, linux-safety

On 8/13/20 11:02 AM, Shuah Khan via lists.elisa.tech wrote:
> On 8/13/20 9:41 AM, Sudip Mukherjee wrote:
>>
>>
>> On 13/08/2020 16:33, Lukas Bulwahn wrote:
>>> Sorry for top posting.
>>>
>>>
>>> No, safety is CERTAINLY NOT a category. Security maybe, but even better
>>> would be a category like “information leaks” and a subset
>>> “kernel-internal information leaks” for your specific coccinelle rule
>>> addressing CWE-547.
>>>
> 
> +1
> 
>>>
>>> For me, for now, misc is okay, but if we want to restructure and
>>> clean-up, we should come up with a complete picture that fits for all.
>>
>> imho, misc is ok for this one, but when you actually make a cocci script
>> for CWE-414 ("Missing Lock Check"), that should be going to
>> scripts/coccinelle/locks/
>>
> 
> +1
> Agree with Lukas and Sudip on directory - safety isn't appropriate here.
> 
> You can find a suitable place: current coverage areas under
> scripts/coccinelle are
> 
> api  free  iterators  locks  misc  null  tests
> 
> Let's try to map new scripts to these categories or create a new
> category when one doesn't exist.
> 

One more thing. Also look into if these issues can be found by compiler.
If so, is there a need to come up with coccinelle script.

Somehow this sounds like a basic error compiler should be able to flag
and might already have a method in the kernel.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
@ 2020-08-13 15:45 Lukas Bulwahn
  0 siblings, 0 replies; 10+ messages in thread
From: Lukas Bulwahn @ 2020-08-13 15:45 UTC (permalink / raw)
  To: sudip.mukherjee, mab; +Cc: skhan, linux-safety

> imho, misc is ok for this one, but when you actually make a cocci script for
> CWE-414 ("Missing Lock Check"), that should be going to
> scripts/coccinelle/locks/
> 

Agree. Locking checks go to locks.

The example of CWE-414 was just to show a suitable format for adding the CWE mapping into the tools/rules as comments and maintain the mapping there.


Lukas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
       [not found]   ` <162ADAEB16525C4A.3117@lists.elisa.tech>
@ 2020-08-13 14:45     ` Mohammed Billoo
  0 siblings, 0 replies; 10+ messages in thread
From: Mohammed Billoo @ 2020-08-13 14:45 UTC (permalink / raw)
  To: Mohammed Billoo; +Cc: Shuah Khan, linux-safety

[-- Attachment #1: Type: text/plain, Size: 2065 bytes --]

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
<mab=mab-labs.com@lists.elisa.tech> 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 <skhan@linuxfoundation.org>
> 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

[-- Attachment #2: Type: text/html, Size: 3137 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
  2020-08-13 14:39 ` [linux-safety] " Shuah Khan
@ 2020-08-13 14:41   ` Mohammed Billoo
       [not found]   ` <162ADAEB16525C4A.3117@lists.elisa.tech>
  1 sibling, 0 replies; 10+ messages in thread
From: Mohammed Billoo @ 2020-08-13 14:41 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-safety

[-- Attachment #1: Type: text/plain, Size: 1497 bytes --]

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 <skhan@linuxfoundation.org>
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

[-- Attachment #2: Type: text/html, Size: 2170 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants
  2020-08-12 23:43 Mohammed Billoo
@ 2020-08-13 14:39 ` Shuah Khan
  2020-08-13 14:41   ` Mohammed Billoo
       [not found]   ` <162ADAEB16525C4A.3117@lists.elisa.tech>
  0 siblings, 2 replies; 10+ messages in thread
From: Shuah Khan @ 2020-08-13 14:39 UTC (permalink / raw)
  To: Mohammed Billoo, linux-safety

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-13 19:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 15:16 [linux-safety] [PATCH] coccinelle: misc: Check for hard-coded constants Lukas Bulwahn
2020-08-13 15:23 ` Mohammed Billoo
2020-08-13 15:33   ` Lukas Bulwahn
2020-08-13 15:41     ` Sudip Mukherjee
2020-08-13 17:02       ` Shuah Khan
     [not found]       ` <162AE2925F9D984B.16363@lists.elisa.tech>
2020-08-13 19:43         ` Shuah Khan
  -- strict thread matches above, loose matches on Subject: below --
2020-08-13 15:45 Lukas Bulwahn
2020-08-12 23:43 Mohammed Billoo
2020-08-13 14:39 ` [linux-safety] " Shuah Khan
2020-08-13 14:41   ` Mohammed Billoo
     [not found]   ` <162ADAEB16525C4A.3117@lists.elisa.tech>
2020-08-13 14:45     ` Mohammed Billoo

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