@@ -397,25 +397,26 @@ module InvalidPointerToDerefFlow = DataFlow::Global<InvalidPointerToDerefConfig>
397397 * case `delta` is 1.
398398 */
399399predicate invalidPointerToDerefSource (
400- AllocToInvalidPointerFlow:: PathNode1 source1 , PointerArithmeticInstruction pai ,
401- DataFlow:: Node source , int delta
400+ DataFlow:: Node source1 , PointerArithmeticInstruction pai , DataFlow:: Node derefSource , int delta
402401) {
403402 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
406406 |
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
411412 // Note that `delta` is not necessarily equal to `delta0`:
412413 // `delta0` is the constant offset added to the size of the allocation, and
413414 // delta is the constant difference between the pointer-arithmetic instruction
414415 // and the instruction computing the address for which we will search for a dereference.
415416 isSinkImpl ( pai , sink1 , sink2 , delta0 ) and
416- bounded2 ( source .asInstruction ( ) , pai , delta ) and
417+ bounded2 ( derefSource .asInstruction ( ) , pai , delta ) and
417418 delta >= 0 and
418- not source .getBasicBlock ( ) = Barrier2:: getABarrierBlock ( delta0 )
419+ not derefSource .getBasicBlock ( ) = Barrier2:: getABarrierBlock ( delta0 )
419420 )
420421}
421422
@@ -496,9 +497,8 @@ module FinalConfig implements DataFlow::StateConfigSig {
496497
497498 predicate isSource ( DataFlow:: Node source , FlowState state ) {
498499 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
502502 InvalidPointerToDerefFlow:: flow ( derefSource , _)
503503 )
504504 }
@@ -552,14 +552,16 @@ query predicate subpaths(
552552}
553553
554554predicate 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
557558) {
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
561563 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
563565 delta = delta0 + delta1
564566 )
565567}
@@ -571,7 +573,7 @@ where
571573 k =
572574 min ( int k2 , int k3 , InvalidPointerToDerefFlow:: PathNode source3 |
573575 hasFlowPath ( source , sink , source3 , pai , operation , k3 ) and
574- invalidPointerToDerefSource ( _ , pai , source3 .getNode ( ) , k2 )
576+ invalidPointerToDerefSource ( source . asPathNode ( ) . getNode ( ) , pai , source3 .getNode ( ) , k2 )
575577 |
576578 k2 + k3
577579 ) and
0 commit comments