@@ -2,8 +2,11 @@ private import codeql.ssa.Ssa as SsaImplCommon
22private import semmle.code.cpp.ir.IR
33private import DataFlowUtil
44private import DataFlowImplCommon as DataFlowImplCommon
5+ private import semmle.code.cpp.ir.dataflow.internal.ModelUtil
56private import semmle.code.cpp.models.interfaces.Allocation as Alloc
67private import semmle.code.cpp.models.interfaces.DataFlow as DataFlow
8+ private import semmle.code.cpp.models.interfaces.FlowOutBarrier as FOB
9+ private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs as FIO
710private import semmle.code.cpp.ir.internal.IRCppLanguage
811private import DataFlowPrivate
912private import ssa0.SsaInternals as SsaInternals0
@@ -784,10 +787,30 @@ private Node getAPriorDefinition(SsaDefOrUse defOrUse) {
784787 )
785788}
786789
790+ /**
791+ * Holds if there should not be use-use flow out of `n` (or a conversion that
792+ * flows to `n`).
793+ */
794+ private predicate modeledFlowBarrier ( Node n ) {
795+ exists ( FIO:: FunctionInput input , CallInstruction call |
796+ call .getStaticCallTarget ( ) .( FOB:: FlowOutBarrierFunction ) .isFlowOutBarrier ( input ) and
797+ n = callInput ( call , input )
798+ )
799+ or
800+ exists ( Operand operand , Instruction instr , Node n0 , int indirectionIndex |
801+ modeledFlowBarrier ( n0 ) and
802+ nodeHasInstruction ( n0 , instr , indirectionIndex ) and
803+ conversionFlow ( operand , instr , false , _) and
804+ nodeHasOperand ( n , operand , indirectionIndex )
805+ )
806+ }
807+
787808/** Holds if there is def-use or use-use flow from `nodeFrom` to `nodeTo`. */
788809predicate ssaFlow ( Node nodeFrom , Node nodeTo ) {
789810 exists ( Node nFrom , boolean uncertain , SsaDefOrUse defOrUse |
790- ssaFlowImpl ( defOrUse , nFrom , nodeTo , uncertain ) and nodeFrom != nodeTo
811+ ssaFlowImpl ( defOrUse , nFrom , nodeTo , uncertain ) and
812+ not modeledFlowBarrier ( nFrom ) and
813+ nodeFrom != nodeTo
791814 |
792815 if uncertain = true then nodeFrom = [ nFrom , getAPriorDefinition ( defOrUse ) ] else nodeFrom = nFrom
793816 )
0 commit comments