@@ -397,25 +397,26 @@ module InvalidPointerToDerefFlow = DataFlow::Global<InvalidPointerToDerefConfig>
397
397
* case `delta` is 1.
398
398
*/
399
399
predicate invalidPointerToDerefSource (
400
- AllocToInvalidPointerFlow:: PathNode1 source1 , PointerArithmeticInstruction pai ,
401
- DataFlow:: Node source , int delta
400
+ DataFlow:: Node source1 , PointerArithmeticInstruction pai , DataFlow:: Node derefSource , int delta
402
401
) {
403
402
exists (
404
- AllocToInvalidPointerFlow:: PathNode1 p1 , AllocToInvalidPointerFlow:: PathNode2 p2 ,
405
- DataFlow:: Node sink1 , DataFlow:: Node sink2 , int delta0
403
+ AllocToInvalidPointerFlow:: PathNode1 pSource1 , AllocToInvalidPointerFlow:: PathNode1 pSink1 ,
404
+ AllocToInvalidPointerFlow:: PathNode2 pSink2 , DataFlow:: Node sink1 , DataFlow:: Node sink2 ,
405
+ int delta0
406
406
|
407
- pragma [ only_bind_out ] ( p1 .getNode ( ) ) = sink1 and
408
- pragma [ only_bind_out ] ( p2 .getNode ( ) ) = sink2 and
409
- AllocToInvalidPointerFlow:: flowPath ( source1 , _, pragma [ only_bind_into ] ( p1 ) ,
410
- pragma [ only_bind_into ] ( p2 ) ) and
407
+ pragma [ only_bind_out ] ( pSource1 .getNode ( ) ) = source1 and
408
+ pragma [ only_bind_out ] ( pSink1 .getNode ( ) ) = sink1 and
409
+ pragma [ only_bind_out ] ( pSink2 .getNode ( ) ) = sink2 and
410
+ AllocToInvalidPointerFlow:: flowPath ( pSource1 , _, pragma [ only_bind_into ] ( pSink1 ) ,
411
+ pragma [ only_bind_into ] ( pSink2 ) ) and
411
412
// Note that `delta` is not necessarily equal to `delta0`:
412
413
// `delta0` is the constant offset added to the size of the allocation, and
413
414
// delta is the constant difference between the pointer-arithmetic instruction
414
415
// and the instruction computing the address for which we will search for a dereference.
415
416
isSinkImpl ( pai , sink1 , sink2 , delta0 ) and
416
- bounded2 ( source .asInstruction ( ) , pai , delta ) and
417
+ bounded2 ( derefSource .asInstruction ( ) , pai , delta ) and
417
418
delta >= 0 and
418
- not source .getBasicBlock ( ) = Barrier2:: getABarrierBlock ( delta0 )
419
+ not derefSource .getBasicBlock ( ) = Barrier2:: getABarrierBlock ( delta0 )
419
420
)
420
421
}
421
422
@@ -496,9 +497,8 @@ module FinalConfig implements DataFlow::StateConfigSig {
496
497
497
498
predicate isSource ( DataFlow:: Node source , FlowState state ) {
498
499
state = TInitial ( ) and
499
- exists ( AllocToInvalidPointerFlow:: PathNode1 p , DataFlow:: Node derefSource |
500
- source = p .getNode ( ) and
501
- invalidPointerToDerefSource ( p , _, derefSource , _) and
500
+ exists ( DataFlow:: Node derefSource |
501
+ invalidPointerToDerefSource ( source , _, derefSource , _) and
502
502
InvalidPointerToDerefFlow:: flow ( derefSource , _)
503
503
)
504
504
}
@@ -552,14 +552,16 @@ query predicate subpaths(
552
552
}
553
553
554
554
predicate hasFlowPath (
555
- MergedPathNode source , MergedPathNode sink , InvalidPointerToDerefFlow:: PathNode source3 ,
556
- PointerArithmeticInstruction pai , string operation , int delta
555
+ MergedPathNode mergedSource , MergedPathNode mergedSink ,
556
+ InvalidPointerToDerefFlow:: PathNode source3 , PointerArithmeticInstruction pai , string operation ,
557
+ int delta
557
558
) {
558
- exists ( FinalFlow:: PathNode sink3 , int delta0 , int delta1 |
559
- FinalFlow:: flowPath ( source .asPathNode ( ) , sink3 ) and
560
- invalidPointerToDerefSource ( _, pai , source3 .getNode ( ) , delta0 ) and
559
+ exists ( FinalFlow:: PathNode source , FinalFlow:: PathNode sink3 , int delta0 , int delta1 |
560
+ source = mergedSource .asPathNode ( ) and
561
+ FinalFlow:: flowPath ( source , sink3 ) and
562
+ invalidPointerToDerefSource ( source .getNode ( ) , pai , source3 .getNode ( ) , delta0 ) and
561
563
sink3 .getState ( ) = FinalConfig:: TPointerArith ( pai , delta0 ) and
562
- isInvalidPointerDerefSink ( sink3 .getNode ( ) , sink .asSinkNode ( ) , operation , delta1 ) and
564
+ isInvalidPointerDerefSink ( sink3 .getNode ( ) , mergedSink .asSinkNode ( ) , operation , delta1 ) and
563
565
delta = delta0 + delta1
564
566
)
565
567
}
@@ -571,7 +573,7 @@ where
571
573
k =
572
574
min ( int k2 , int k3 , InvalidPointerToDerefFlow:: PathNode source3 |
573
575
hasFlowPath ( source , sink , source3 , pai , operation , k3 ) and
574
- invalidPointerToDerefSource ( _ , pai , source3 .getNode ( ) , k2 )
576
+ invalidPointerToDerefSource ( source . asPathNode ( ) . getNode ( ) , pai , source3 .getNode ( ) , k2 )
575
577
|
576
578
k2 + k3
577
579
) and
0 commit comments