@@ -38,14 +38,25 @@ predicate strictlyDominates(IRBlock b1, int i1, IRBlock b2, int i2) {
3838 b1 .strictlyDominates ( b2 )
3939}
4040
41+ predicate sinkStrictlyPostDominatesSource ( DataFlow:: Node source , DataFlow:: Node sink ) {
42+ exists ( IRBlock b1 , int i1 , IRBlock b2 , int i2 |
43+ source .hasIndexInBlock ( b1 , i1 ) and
44+ sink .hasIndexInBlock ( b2 , i2 ) and
45+ strictlyPostDominates ( b2 , i2 , b1 , i1 )
46+ )
47+ }
48+
49+ predicate sourceStrictlyDominatesSink ( DataFlow:: Node source , DataFlow:: Node sink ) {
50+ exists ( IRBlock b1 , int i1 , IRBlock b2 , int i2 |
51+ source .hasIndexInBlock ( b1 , i1 ) and
52+ sink .hasIndexInBlock ( b2 , i2 ) and
53+ strictlyDominates ( b1 , i1 , b2 , i2 )
54+ )
55+ }
56+
4157/**
4258 * Constructs a `FlowFromFreeConfig` module that can be used to find flow between
4359 * a pointer being freed by some deallocation function, and a user-specified sink.
44- *
45- * In order to reduce false positives, the set of sinks is restricted to only those
46- * that satisfy at least one of the following two criteria:
47- * 1. The source dominates the sink, or
48- * 2. The sink post-dominates the source.
4960 */
5061module FlowFromFree< isSinkSig / 2 isASink, isExcludedSig / 2 isExcluded> {
5162 module FlowFromFreeConfig implements DataFlow:: StateConfigSig {
@@ -59,20 +70,11 @@ module FlowFromFree<isSinkSig/2 isASink, isExcludedSig/2 isExcluded> {
5970
6071 pragma [ inline]
6172 predicate isSink ( DataFlow:: Node sink , FlowState state ) {
62- exists (
63- Expr e , DataFlow:: Node source , IRBlock b1 , int i1 , IRBlock b2 , int i2 ,
64- DeallocationExpr dealloc
65- |
73+ exists ( Expr e , DeallocationExpr dealloc |
6674 isASink ( sink , e ) and
67- isFree ( source , _, state , dealloc ) and
75+ isFree ( _ , _, state , dealloc ) and
6876 e != state and
69- source .hasIndexInBlock ( b1 , i1 ) and
70- sink .hasIndexInBlock ( b2 , i2 ) and
7177 not isExcluded ( dealloc , e )
72- |
73- strictlyDominates ( b1 , i1 , b2 , i2 )
74- or
75- strictlyPostDominates ( b2 , i2 , b1 , i1 )
7678 )
7779 }
7880
0 commit comments