From 4381bae5d1481b161096986fb30b1e426205b369 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 26 Aug 2024 14:10:40 +0200 Subject: [PATCH 1/2] Shared: Fix bad join. --- .../dataflow/internal/ContentDataFlowImpl.qll | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll b/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll index a4d3e413625..1823a25155f 100644 --- a/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll +++ b/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll @@ -455,27 +455,42 @@ module MakeImplContentDataFlow Lang> { ) } + pragma[nomagic] + private predicate nodeAndState(Flow::PathNode n, Node node, State state) { + n.getNode() = node and n.getState() = state + } + + pragma[nomagic] + private predicate succNodeAndState( + Flow::PathNode pre, Node preNode, State preState, Flow::PathNode succ, Node succNode, + State succState + ) { + nodeAndState(pre, preNode, preState) and + nodeAndState(succ, succNode, succState) and + pre.getASuccessor() = succ + } + pragma[nomagic] private predicate nodeReachesStore( - Flow::PathNode source, AccessPath scReads, AccessPath scStores, Flow::PathNode node, + Flow::PathNode source, AccessPath scReads, AccessPath scStores, Flow::PathNode target, ContentSet c, AccessPath reads, AccessPath stores ) { - exists(Flow::PathNode mid | + exists(Flow::PathNode mid, State midState, Node midNode, State targetState, Node targetNode | nodeReaches(source, scReads, scStores, mid, reads, stores) and - storeStep(mid.getNode(), mid.getState(), c, node.getNode(), node.getState()) and - mid.getASuccessor() = node + succNodeAndState(mid, midNode, midState, target, targetNode, targetState) and + storeStep(midNode, midState, c, targetNode, targetState) ) } pragma[nomagic] private predicate nodeReachesRead( - Flow::PathNode source, AccessPath scReads, AccessPath scStores, Flow::PathNode node, + Flow::PathNode source, AccessPath scReads, AccessPath scStores, Flow::PathNode target, ContentSet c, AccessPath reads, AccessPath stores ) { - exists(Flow::PathNode mid | + exists(Flow::PathNode mid, State midState, Node midNode, State targetState, Node targetNode | nodeReaches(source, scReads, scStores, mid, reads, stores) and - readStep(mid.getNode(), mid.getState(), c, node.getNode(), node.getState()) and - mid.getASuccessor() = node + succNodeAndState(mid, midNode, midState, target, targetNode, targetState) and + readStep(midNode, midState, c, targetNode, targetState) ) } From 77bfe39ca7a4b85b9e322a9e13f0cecb21a773ee Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 26 Aug 2024 15:24:22 +0200 Subject: [PATCH 2/2] Shared: Address review comments. --- .../codeql/dataflow/internal/ContentDataFlowImpl.qll | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll b/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll index 1823a25155f..c63f36bdeda 100644 --- a/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll +++ b/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll @@ -455,18 +455,15 @@ module MakeImplContentDataFlow Lang> { ) } - pragma[nomagic] - private predicate nodeAndState(Flow::PathNode n, Node node, State state) { - n.getNode() = node and n.getState() = state - } - pragma[nomagic] private predicate succNodeAndState( Flow::PathNode pre, Node preNode, State preState, Flow::PathNode succ, Node succNode, State succState ) { - nodeAndState(pre, preNode, preState) and - nodeAndState(succ, succNode, succState) and + pre.getNode() = preNode and + pre.getState() = preState and + succ.getNode() = succNode and + succ.getState() = succState and pre.getASuccessor() = succ }