Skip to content

Commit e594e72

Browse files
committed
Dataflow: Check stateful in/out-barriers in each stage.
1 parent c2b25c7 commit e594e72

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
15781578
fwdFlowThrough(call, cc, state, ccc, summaryCtx, argT, argAp, t, ap, apa, ret,
15791579
innerArgApa) and
15801580
flowThroughOutOfCall(call, ccc, ret, node, allowsFieldFlow, innerArgApa, apa) and
1581+
not inBarrier(node, state) and
15811582
if allowsFieldFlow = false then ap instanceof ApNil else any()
15821583
)
15831584
}
@@ -1610,6 +1611,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
16101611
) {
16111612
exists(DataFlowType contentType, DataFlowType containerType, ApApprox apa1 |
16121613
fwdFlow(node1, state, cc, summaryCtx, argT, argAp, t1, ap1, apa1) and
1614+
not outBarrier(node1, state) and
1615+
not inBarrier(node2, state) and
16131616
PrevStage::storeStepCand(node1, apa1, c, node2, contentType, containerType) and
16141617
t2 = getTyp(containerType) and
16151618
typecheckStore(t1, contentType)
@@ -1651,6 +1654,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
16511654
) {
16521655
exists(ApHeadContent apc |
16531656
fwdFlow(node1, state, cc, summaryCtx, argT, argAp, t, ap, _) and
1657+
not outBarrier(node1, state) and
1658+
not inBarrier(node2, state) and
16541659
apc = getHeadContent(ap) and
16551660
readStepCand0(node1, apc, c, node2)
16561661
)
@@ -1761,6 +1766,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
17611766
or
17621767
viableImplArgNotCallContextReduced(call, arg, outercc)
17631768
) and
1769+
not outBarrier(arg, state) and
1770+
not inBarrier(p, state) and
17641771
callEdgeArgParamRestrictedInlineLate(call, inner, arg, p, allowsFieldFlow, apa) and
17651772
(if allowsFieldFlow = false then emptyAp = true else any()) and
17661773
if allowsFieldFlowThrough(call, inner)
@@ -1888,6 +1895,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
18881895
ApOption argAp, Typ t, Ap ap, ApApprox apa
18891896
) {
18901897
instanceofCcNoCall(cc) and
1898+
not outBarrier(ret, state) and
18911899
fwdFlow(ret, state, cc, summaryCtx, argT, argAp, t, ap, apa)
18921900
}
18931901

@@ -1925,6 +1933,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
19251933
exists(RetNodeEx ret, CcNoCall innercc, boolean allowsFieldFlow |
19261934
fwdFlowIntoRet(ret, state, innercc, summaryCtx, argT, argAp, t, ap, apa) and
19271935
fwdFlowOutValidEdge(call, ret, innercc, inner, out, outercc, apa, allowsFieldFlow) and
1936+
not inBarrier(out, state) and
19281937
if allowsFieldFlow = false then ap instanceof ApNil else any()
19291938
)
19301939
}
@@ -2018,6 +2027,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
20182027
fwdFlow(pragma[only_bind_into](ret), state, ccc,
20192028
TParamNodeSome(pragma[only_bind_into](summaryCtx.asNode())), TypOption::some(argT),
20202029
pragma[only_bind_into](apSome(argAp)), t, ap, pragma[only_bind_into](apa)) and
2030+
not outBarrier(ret, state) and
20212031
kind = ret.getKind() and
20222032
parameterFlowThroughAllowed(summaryCtx, kind) and
20232033
argApa = getApprox(argAp) and
@@ -2839,6 +2849,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
28392849
fwdFlowThroughStep1(pn1, pn2, pn3, call, cc, state, ccc, summaryCtx, argT, argAp, t,
28402850
ap, apa, ret, innerArgApa) and
28412851
flowThroughOutOfCall(call, ccc, ret, node, allowsFieldFlow, innerArgApa, apa) and
2852+
not inBarrier(node, state) and
28422853
if allowsFieldFlow = false then ap instanceof ApNil else any()
28432854
)
28442855
}
@@ -2926,11 +2937,15 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
29262937
|
29272938
jumpStepEx(mid, node) and
29282939
state = state0 and
2940+
not outBarrier(mid, state) and
2941+
not inBarrier(node, state) and
29292942
t = t0 and
29302943
label = ""
29312944
or
29322945
additionalJumpStep(mid, node, label) and
29332946
state = state0 and
2947+
not outBarrier(mid, state) and
2948+
not inBarrier(node, state) and
29342949
t = getNodeTyp(node) and
29352950
ap instanceof ApNil
29362951
or
@@ -2967,6 +2982,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
29672982
pn1 = TStagePathNodeMid(ret, state, innercc, summaryCtx, argT, argAp, t, ap) and
29682983
fwdFlowIntoRet(ret, state, innercc, summaryCtx, argT, argAp, t, ap, apa) and
29692984
fwdFlowOutValidEdge(_, ret, innercc, _, node, cc, apa, allowsFieldFlow) and
2985+
not inBarrier(node, state) and
29702986
label = "" and
29712987
if allowsFieldFlow = false then ap instanceof ApNil else any()
29722988
)

0 commit comments

Comments
 (0)