Skip to contentSkip to conversation

Determination of failure predicates for selected function calls with SmPL?

Cocci Markus Elfring 2 participants 4 messages Mar 25, 2020 – Mar 26, 2020

lore
Share & tools
lore
#0 lore raw

Hello,

I have noticed the patch “tty: serial: fsl_lpuart: fix return value checking”.
https://lore.kernel.org/linux-serial/[email protected]/
https://lore.kernel.org/patchwork/patch/1215542/
https://lkml.org/lkml/2020/3/25/202

I am curious if such a software transformation can be extended for similar source code searches also by the means of the semantic patch language. The proper knowledge of failure predicates for function calls is a key aspect for this use case.
Would you like to clarify any corresponding development possibilities?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#1 lore raw
Quoted 7 lines · Markus Elfring

Hello,

I have noticed the patch “tty: serial: fsl_lpuart: fix return value checking”.
https://lore.kernel.org/linux-serial/[email protected]/
https://lore.kernel.org/patchwork/patch/1215542/
https://lkml.org/lkml/2020/3/25/202

Quoted 5 lines

I am curious if such a software transformation can be extended for similar source code searches also by the means of the semantic patch language. The proper knowledge of failure predicates for function calls is a key aspect for this use case.
Would you like to clarify any corresponding development possibilities?

I'm not sure what there is to clarify. One can surely write rules that find this kind of problem, with a varying rate of false positives.

A simple approach would be to check all occurrences of if (!ret) for an integer-typed variable, because typically that is the success case. But sometimes people do put the success case under an if.

julia

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw
Quoted 2 lines
Quoted 2 lines

I have noticed the patch “tty: serial: fsl_lpuart: fix return value checking”.
https://lore.kernel.org/linux-serial/[email protected]/

…

Quoted 1 line

I'm not sure what there is to clarify.

Such an use case can point some software development challenges out.

Quoted 1 line

One can surely write rules that find this kind of problem,

I know this in principle.

Quoted 1 line

with a varying rate of false positives.

I am trying again to reduce this special case considerably.

Quoted 2 lines

A simple approach would be to check all occurrences of if (!ret) for an integer-typed variable, because typically that is the success case.

I would like to increase the probability for generation of corresponding fixes.

The success predicate can be also the opposite if you would like to take a Linux macro like access_ok() or valid pointers (after memory allocations for example) into account.

Quoted 1 line

But sometimes people do put the success case under an if.

I am curious how often such source code variations should be considered.

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#3 lore raw
In reply to Julia Lawall
Quoted 2 lines
Quoted 2 lines

I have noticed the patch “tty: serial: fsl_lpuart: fix return value checking”.
https://lore.kernel.org/linux-serial/[email protected]/

…

Quoted 2 lines

I'm not sure what there is to clarify. One can surely write rules that find this kind of problem, with a varying rate of false positives.

Will further changes become more interesting also according to other development approaches you care for?

* Prequel
http://prequel-pql.gforge.inria.fr/

* Machine learning for software corrections
https://hal.inria.fr/hal-02373994
https://doi.org/10.1109/TSE.2019.2952614

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci