cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] detecting false positive sparse with coccinelle
@ 2019-04-29  6:05 Nicholas Mc Guire
  2019-04-29 14:42 ` [Cocci] Detecting false positive sparse with Coccinelle Markus Elfring
  2019-04-29 16:26 ` [Cocci] detecting false positive sparse with coccinelle Julia Lawall
  0 siblings, 2 replies; 5+ messages in thread
From: Nicholas Mc Guire @ 2019-04-29  6:05 UTC (permalink / raw)
  To: cocci


Hi !

 I'm trying to detect false positive sparse messages by taking
 the pattern and scanning with coccinelle for it so that the
 fix could be generated. Basically the identification seems
 to be working (a type-check on var is stil missing - but thats
 a different issue) - the problem though is that I'm unable
 to insert the (__force __be16) cast in the patch rule as 
 coccinelle is refusing hose lines. Any hint how that could be 
 done or is the problem the syntactic oddity of having a 
 unknown keyworkd followed by a type that is confusing coccinelle 
 here ?

thx!
hofrat

virtual report
virtual patch

@acheck depends on report@
identifier var;
position p;
@@

(
* var = be16_to_cpu@p(var);
|
* var = be32_to_cpu@p(var);
|
* var = be64_to_cpu@p(var);
|
* var = le16_to_cpu@p(var);
|
* var = le32_to_cpu@p(var);
|
* var = le64_to_cpu@p(var);
)

@script:python depends on report@
p << acheck.p;
@@

msg = "forced endiannes annotation needed"
coccilib.report.print_report(p[0],msg)

@afix depends on patch@
identifier var;
position p;
typedef __be16, __be32, __b64, __le16, __le32, __le64;
@@

(
- var = be16_to_cpu@p(var);
+ var = be16_to_cpu((__force __be16)var);
|
- var = be32_to_cpu@p(var);
+ var = be32_to_cpu((__force __be32)var);
|
- var = be64_to_cpu@p(var);
+ var = be64_to_cpu((__force __be64)var);
|
- var = le16_to_cpu@p(var);
+ var = le16_to_cpu((__force __le16)var);
|
- var = le32_to_cpu@p(var);
+ var = le32_to_cpu((__force __le32)var);
|
- var = le64_to_cpu@p(var);
+ var = le64_to_cpu((__force __le64)var);
)

@script:python depends on patch@
p << afix.p;
@@

msg = "forced endiannes annotation added"
coccilib.report.print_report(p[0],msg)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Detecting false positive sparse with Coccinelle
  2019-04-29  6:05 [Cocci] detecting false positive sparse with coccinelle Nicholas Mc Guire
@ 2019-04-29 14:42 ` Markus Elfring
  2019-04-29 16:26 ` [Cocci] detecting false positive sparse with coccinelle Julia Lawall
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-04-29 14:42 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: cocci

> … - the problem though is that I'm unable
> to insert the (__force __be16) cast in the patch rule as
> coccinelle is refusing hose lines. …

It seems that I can not help directly with this concern. But a few other
implementation details in your approach caught also my development attention
once more.

1. A disjunction is used for the SmPL rule “acheck”.
   I find that duplicated SmPL code can be avoided there.
   How do you think about to specify the desired function names
   by a corresponding SmPL constraint or a nested disjunction?

2. The addition of a cast can be specified in a more succinct way
   for the SmPL rule “afix”.

3. The specification “@script:python depends on patch@” might result in
   undesirable data output.
   Would you like to select an other output channel than
   for the generated diff?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] detecting false positive sparse with coccinelle
  2019-04-29  6:05 [Cocci] detecting false positive sparse with coccinelle Nicholas Mc Guire
  2019-04-29 14:42 ` [Cocci] Detecting false positive sparse with Coccinelle Markus Elfring
@ 2019-04-29 16:26 ` Julia Lawall
  2019-04-30  3:26   ` Nicholas Mc Guire
  1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2019-04-29 16:26 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: cocci



On Mon, 29 Apr 2019, Nicholas Mc Guire wrote:

>
> Hi !
>
>  I'm trying to detect false positive sparse messages by taking
>  the pattern and scanning with coccinelle for it so that the
>  fix could be generated. Basically the identification seems
>  to be working (a type-check on var is stil missing - but thats
>  a different issue) - the problem though is that I'm unable
>  to insert the (__force __be16) cast in the patch rule as
>  coccinelle is refusing hose lines. Any hint how that could be
>  done or is the problem the syntactic oddity of having a
>  unknown keyworkd followed by a type that is confusing coccinelle
>  here ?

Types like this are currently not parsed properly - see the GSoC project.
I'm not sure that there is a good solution at the moment.  This should be
parsed OK by the C parser, so you could try passing through python.  See
python_mdecl.cocci.  It may be necessary to construct the complete
expression (__force __be16)var in python.

julia

>
> thx!
> hofrat
>
> virtual report
> virtual patch
>
> @acheck depends on report@
> identifier var;
> position p;
> @@
>
> (
> * var = be16_to_cpu@p(var);
> |
> * var = be32_to_cpu@p(var);
> |
> * var = be64_to_cpu@p(var);
> |
> * var = le16_to_cpu@p(var);
> |
> * var = le32_to_cpu@p(var);
> |
> * var = le64_to_cpu@p(var);
> )
>
> @script:python depends on report@
> p << acheck.p;
> @@
>
> msg = "forced endiannes annotation needed"
> coccilib.report.print_report(p[0],msg)
>
> @afix depends on patch@
> identifier var;
> position p;
> typedef __be16, __be32, __b64, __le16, __le32, __le64;
> @@
>
> (
> - var = be16_to_cpu@p(var);
> + var = be16_to_cpu((__force __be16)var);
> |
> - var = be32_to_cpu@p(var);
> + var = be32_to_cpu((__force __be32)var);
> |
> - var = be64_to_cpu@p(var);
> + var = be64_to_cpu((__force __be64)var);
> |
> - var = le16_to_cpu@p(var);
> + var = le16_to_cpu((__force __le16)var);
> |
> - var = le32_to_cpu@p(var);
> + var = le32_to_cpu((__force __le32)var);
> |
> - var = le64_to_cpu@p(var);
> + var = le64_to_cpu((__force __le64)var);
> )
>
> @script:python depends on patch@
> p << afix.p;
> @@
>
> msg = "forced endiannes annotation added"
> coccilib.report.print_report(p[0],msg)
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] detecting false positive sparse with coccinelle
  2019-04-29 16:26 ` [Cocci] detecting false positive sparse with coccinelle Julia Lawall
@ 2019-04-30  3:26   ` Nicholas Mc Guire
  2019-04-30 10:56     ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Mc Guire @ 2019-04-30  3:26 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

On Mon, Apr 29, 2019 at 12:26:49PM -0400, Julia Lawall wrote:
> 
> 
> On Mon, 29 Apr 2019, Nicholas Mc Guire wrote:
> 
> >
> > Hi !
> >
> >  I'm trying to detect false positive sparse messages by taking
> >  the pattern and scanning with coccinelle for it so that the
> >  fix could be generated. Basically the identification seems
> >  to be working (a type-check on var is stil missing - but thats
> >  a different issue) - the problem though is that I'm unable
> >  to insert the (__force __be16) cast in the patch rule as
> >  coccinelle is refusing hose lines. Any hint how that could be
> >  done or is the problem the syntactic oddity of having a
> >  unknown keyworkd followed by a type that is confusing coccinelle
> >  here ?
> 
> Types like this are currently not parsed properly - see the GSoC project.
> I'm not sure that there is a good solution at the moment.  This should be
> parsed OK by the C parser, so you could try passing through python.  See
> python_mdecl.cocci.  It may be necessary to construct the complete
> expression (__force __be16)var in python.
>
ok - so I guess this means the issue applies to all type attributes
then. Using python might be doable but the goal is to not grow the
number of involved tools - there are already too many anyway.
I'll try poking around in coccinelle then - not sure how hard that 
would be to add that - something like an typedef equivalent called
attributedef would be my first guess.

thx!
hofrat 
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] detecting false positive sparse with coccinelle
  2019-04-30  3:26   ` Nicholas Mc Guire
@ 2019-04-30 10:56     ` Julia Lawall
  0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2019-04-30 10:56 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: cocci



On Tue, 30 Apr 2019, Nicholas Mc Guire wrote:

> On Mon, Apr 29, 2019 at 12:26:49PM -0400, Julia Lawall wrote:
> >
> >
> > On Mon, 29 Apr 2019, Nicholas Mc Guire wrote:
> >
> > >
> > > Hi !
> > >
> > >  I'm trying to detect false positive sparse messages by taking
> > >  the pattern and scanning with coccinelle for it so that the
> > >  fix could be generated. Basically the identification seems
> > >  to be working (a type-check on var is stil missing - but thats
> > >  a different issue) - the problem though is that I'm unable
> > >  to insert the (__force __be16) cast in the patch rule as
> > >  coccinelle is refusing hose lines. Any hint how that could be
> > >  done or is the problem the syntactic oddity of having a
> > >  unknown keyworkd followed by a type that is confusing coccinelle
> > >  here ?
> >
> > Types like this are currently not parsed properly - see the GSoC project.
> > I'm not sure that there is a good solution at the moment.  This should be
> > parsed OK by the C parser, so you could try passing through python.  See
> > python_mdecl.cocci.  It may be necessary to construct the complete
> > expression (__force __be16)var in python.
> >
> ok - so I guess this means the issue applies to all type attributes
> then. Using python might be doable but the goal is to not grow the
> number of involved tools - there are already too many anyway.
> I'll try poking around in coccinelle then - not sure how hard that
> would be to add that - something like an typedef equivalent called
> attributedef would be my first guess.

Some attributes are supported, but not in casts.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, other threads:[~2019-04-30 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29  6:05 [Cocci] detecting false positive sparse with coccinelle Nicholas Mc Guire
2019-04-29 14:42 ` [Cocci] Detecting false positive sparse with Coccinelle Markus Elfring
2019-04-29 16:26 ` [Cocci] detecting false positive sparse with coccinelle Julia Lawall
2019-04-30  3:26   ` Nicholas Mc Guire
2019-04-30 10:56     ` Julia Lawall

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