@@ -53,9 +53,15 @@ module MakeImpl<InputSig Lang> {
53
53
/** Holds if data flow into `node` is prohibited. */
54
54
predicate isBarrierIn ( Node node ) ;
55
55
56
+ /** Holds if data flow into `node` is prohibited when the target flow state is `state`. */
57
+ predicate isBarrierIn ( Node node , FlowState state ) ;
58
+
56
59
/** Holds if data flow out of `node` is prohibited. */
57
60
predicate isBarrierOut ( Node node ) ;
58
61
62
+ /** Holds if data flow out of `node` is prohibited when the originating flow state is `state`. */
63
+ predicate isBarrierOut ( Node node , FlowState state ) ;
64
+
59
65
/**
60
66
* Holds if data may flow from `node1` to `node2` in addition to the normal data-flow steps.
61
67
*/
@@ -133,6 +139,10 @@ module MakeImpl<InputSig Lang> {
133
139
134
140
predicate isBarrier ( Node node , FlowState state ) { none ( ) }
135
141
142
+ predicate isBarrierIn ( Node node , FlowState state ) { none ( ) }
143
+
144
+ predicate isBarrierOut ( Node node , FlowState state ) { none ( ) }
145
+
136
146
predicate isAdditionalFlowStep ( Node node1 , FlowState state1 , Node node2 , FlowState state2 ) {
137
147
none ( )
138
148
}
@@ -220,6 +230,14 @@ module MakeImpl<InputSig Lang> {
220
230
)
221
231
}
222
232
233
+ private predicate inBarrier ( NodeEx node , FlowState state ) {
234
+ exists ( Node n |
235
+ node .asNode ( ) = n and
236
+ Config:: isBarrierIn ( n , state ) and
237
+ Config:: isSource ( n , state )
238
+ )
239
+ }
240
+
223
241
private predicate outBarrier ( NodeEx node ) {
224
242
exists ( Node n |
225
243
node .asNode ( ) = n and
@@ -231,6 +249,17 @@ module MakeImpl<InputSig Lang> {
231
249
)
232
250
}
233
251
252
+ private predicate outBarrier ( NodeEx node , FlowState state ) {
253
+ exists ( Node n |
254
+ node .asNode ( ) = n and
255
+ Config:: isBarrierOut ( n , state )
256
+ |
257
+ Config:: isSink ( n , state )
258
+ or
259
+ Config:: isSink ( n )
260
+ )
261
+ }
262
+
234
263
pragma [ nomagic]
235
264
private predicate fullBarrier ( NodeEx node ) {
236
265
exists ( Node n | node .asNode ( ) = n |
@@ -247,7 +276,16 @@ module MakeImpl<InputSig Lang> {
247
276
248
277
pragma [ nomagic]
249
278
private predicate stateBarrier ( NodeEx node , FlowState state ) {
250
- exists ( Node n | node .asNode ( ) = n | Config:: isBarrier ( n , state ) )
279
+ exists ( Node n | node .asNode ( ) = n |
280
+ Config:: isBarrier ( n , state )
281
+ or
282
+ Config:: isBarrierIn ( n , state ) and
283
+ not Config:: isSource ( n , state )
284
+ or
285
+ Config:: isBarrierOut ( n , state ) and
286
+ not Config:: isSink ( n , state ) and
287
+ not Config:: isSink ( n )
288
+ )
251
289
}
252
290
253
291
pragma [ nomagic]
@@ -265,6 +303,7 @@ module MakeImpl<InputSig Lang> {
265
303
}
266
304
267
305
/** Provides the relevant barriers for a step from `node1` to `node2`. */
306
+ bindingset [ node1, node2]
268
307
pragma [ inline]
269
308
private predicate stepFilter ( NodeEx node1 , NodeEx node2 ) {
270
309
not outBarrier ( node1 ) and
@@ -273,6 +312,17 @@ module MakeImpl<InputSig Lang> {
273
312
not fullBarrier ( node2 )
274
313
}
275
314
315
+ /** Provides the relevant barriers for a step from `node1,state1` to `node2,state2`, including stateless barriers for `node1` to `node2`. */
316
+ bindingset [ node1, state1, node2, state2]
317
+ pragma [ inline]
318
+ private predicate stateStepFilter ( NodeEx node1 , FlowState state1 , NodeEx node2 , FlowState state2 ) {
319
+ stepFilter ( node1 , node2 ) and
320
+ not outBarrier ( node1 , state1 ) and
321
+ not inBarrier ( node2 , state2 ) and
322
+ not stateBarrier ( node1 , state1 ) and
323
+ not stateBarrier ( node2 , state2 )
324
+ }
325
+
276
326
pragma [ nomagic]
277
327
private predicate isUnreachableInCall1 ( NodeEx n , LocalCallContextSpecificCall cc ) {
278
328
isUnreachableInCallCached ( n .asNode ( ) , cc .getCall ( ) )
@@ -325,9 +375,7 @@ module MakeImpl<InputSig Lang> {
325
375
node2 .asNode ( ) = n2 and
326
376
Config:: isAdditionalFlowStep ( pragma [ only_bind_into ] ( n1 ) , s1 , pragma [ only_bind_into ] ( n2 ) , s2 ) and
327
377
getNodeEnclosingCallable ( n1 ) = getNodeEnclosingCallable ( n2 ) and
328
- stepFilter ( node1 , node2 ) and
329
- not stateBarrier ( node1 , s1 ) and
330
- not stateBarrier ( node2 , s2 )
378
+ stateStepFilter ( node1 , s1 , node2 , s2 )
331
379
)
332
380
}
333
381
@@ -364,9 +412,7 @@ module MakeImpl<InputSig Lang> {
364
412
node2 .asNode ( ) = n2 and
365
413
Config:: isAdditionalFlowStep ( pragma [ only_bind_into ] ( n1 ) , s1 , pragma [ only_bind_into ] ( n2 ) , s2 ) and
366
414
getNodeEnclosingCallable ( n1 ) != getNodeEnclosingCallable ( n2 ) and
367
- stepFilter ( node1 , node2 ) and
368
- not stateBarrier ( node1 , s1 ) and
369
- not stateBarrier ( node2 , s2 ) and
415
+ stateStepFilter ( node1 , s1 , node2 , s2 ) and
370
416
not Config:: getAFeature ( ) instanceof FeatureEqualSourceSinkCallContext
371
417
)
372
418
}
0 commit comments