detecting false positive sparse with coccinelle
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Detecting false positive sparse with Coccinelle
Quoted 3 lines
… - 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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 13 lines · Nicholas Mc Guire
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
Quoted 63 lines
thx!
hofratvirtual 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;
@@
Quoted 7 lines
msg = "forced endiannes annotation added"
coccilib.report.print_report(p[0],msg)
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 18 lines · Julia Lawall
Quoted 13 lines · Nicholas Mc Guire
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 ?
Quoted 6 lines
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 25 lines · Nicholas Mc Guire
Quoted 18 lines · Julia Lawall
Quoted 13 lines · Nicholas Mc Guire
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 ?Quoted 6 lines
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.
Quoted 6 lines
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci