Skip to content

Commit 2031b0c

Browse files
committed
temp
1 parent ff94f08 commit 2031b0c

File tree

2 files changed

+96
-134
lines changed

2 files changed

+96
-134
lines changed

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

+47-51
Original file line numberDiff line numberDiff line change
@@ -1582,17 +1582,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
15821582
)
15831583
or
15841584
// read
1585-
exists(Typ t0, Ap ap0, Content c |
1586-
fwdFlowRead(t0, ap0, c, _, node, state, cc, summaryCtx, argT, argAp) and
1587-
apa = getApprox(ap)
1588-
|
1589-
exists(NodeEx storeSource |
1590-
fwdFlowConsCandStoreReadMatchingEnabled(storeSource, t0, ap0, c, t, ap) and
1591-
storeMayReachReadInlineLate(storeSource, c, node)
1592-
)
1593-
or
1594-
fwdFlowConsCandStoreReadMatchingDisabled(t0, ap0, c, t, ap)
1595-
)
1585+
fwdFlowRead(_, _, t, ap, _, _, node, state, cc, summaryCtx, argT, argAp) and
1586+
apa = getApprox(ap)
15961587
or
15971588
// flow into a callable
15981589
exists(boolean allowsFlowThrough |
@@ -1720,7 +1711,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
17201711
}
17211712

17221713
pragma[nomagic]
1723-
private predicate fwdFlowRead(
1714+
private predicate fwdFlowRead0(
17241715
Typ t, Ap ap, Content c, NodeEx node1, NodeEx node2, FlowState state, Cc cc,
17251716
ParamNodeOption summaryCtx, TypOption argT, ApOption argAp
17261717
) {
@@ -1731,6 +1722,22 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
17311722
)
17321723
}
17331724

1725+
pragma[inline]
1726+
private predicate fwdFlowRead(
1727+
Typ t1, Ap ap1, Typ t2, Ap ap2, Content c, NodeEx node1, NodeEx node2, FlowState state,
1728+
Cc cc, ParamNodeOption summaryCtx, TypOption argT, ApOption argAp
1729+
) {
1730+
fwdFlowRead0(t1, ap1, c, node1, node2, state, cc, summaryCtx, argT, argAp) and
1731+
(
1732+
exists(NodeEx storeSource |
1733+
fwdFlowConsCandStoreReadMatchingEnabled(storeSource, t1, ap1, c, t2, ap2) and
1734+
storeMayReachReadInlineLate(storeSource, c, node2)
1735+
)
1736+
or
1737+
fwdFlowConsCandStoreReadMatchingDisabled(t1, ap1, c, t2, ap2)
1738+
)
1739+
}
1740+
17341741
pragma[nomagic]
17351742
private predicate fwdFlowIntoArg(
17361743
ArgNodeEx arg, FlowState state, Cc outercc, ParamNodeOption summaryCtx, TypOption argT,
@@ -2151,14 +2158,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
21512158

21522159
pragma[nomagic]
21532160
private predicate readStepFwd(NodeEx n1, Ap ap1, Content c, NodeEx n2, Ap ap2) {
2154-
exists(Typ t1 | fwdFlowRead(t1, ap1, c, n1, n2, _, _, _, _, _) |
2155-
exists(NodeEx storeSource |
2156-
fwdFlowConsCandStoreReadMatchingEnabled(storeSource, t1, ap1, c, _, ap2) and
2157-
storeMayReachReadInlineLate(storeSource, c, n2)
2158-
)
2159-
or
2160-
fwdFlowConsCandStoreReadMatchingDisabled(t1, ap1, c, _, ap2)
2161-
)
2161+
fwdFlowRead(_, ap1, _, ap2, c, n1, n2, _, _, _, _, _)
21622162
}
21632163

21642164
pragma[nomagic]
@@ -2275,7 +2275,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
22752275
revFlowStore(ap0, c, ap, _, node, state, _, returnCtx, returnAp)
22762276
|
22772277
exists(NodeEx readTarget |
2278-
revFlowConsCand(readTarget, ap0, c, ap) and
2278+
revFlowConsCandStoreReadMatchingEnabled(readTarget, ap0, c, ap) and
22792279
storeMayReachReadInlineLate(node, c, readTarget)
22802280
)
22812281
or
@@ -2340,11 +2340,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
23402340
storeStepFwd(node, t, ap, c, mid, ap0)
23412341
}
23422342

2343-
/**
2344-
* Holds if reverse flow with access path `tail` reaches a read of `c`
2345-
* resulting in access path `cons`.
2346-
*/
2347-
pragma[nomagic]
2343+
pragma[inline]
23482344
private predicate revFlowConsCand(NodeEx readTarget, Ap cons, Content c, Ap tail) {
23492345
exists(Ap tail0 |
23502346
revFlow(readTarget, _, _, _, tail) and
@@ -2356,6 +2352,23 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
23562352
/**
23572353
* Holds if reverse flow with access path `tail` reaches a read of `c`
23582354
* resulting in access path `cons`.
2355+
*
2356+
* This predicate is only evaluated when `enableStoreReadMatching()` holds.
2357+
*/
2358+
pragma[nomagic]
2359+
private predicate revFlowConsCandStoreReadMatchingEnabled(
2360+
NodeEx readTarget, Ap cons, Content c, Ap tail
2361+
) {
2362+
enableStoreReadMatching() and
2363+
revFlowConsCand(readTarget, cons, c, tail)
2364+
}
2365+
2366+
/**
2367+
* Holds if reverse flow with access path `tail` reaches a read of `c`
2368+
* resulting in access path `cons`.
2369+
*
2370+
* This predicate is only evaluated when `enableStoreReadMatching()`
2371+
* doesn't hold.
23592372
*/
23602373
pragma[nomagic]
23612374
private predicate revFlowConsCandStoreReadMatchingDisabled(Ap cons, Content c, Ap tail) {
@@ -2823,17 +2836,10 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
28232836
)
28242837
or
28252838
// read
2826-
exists(NodeEx mid, Typ t0, Ap ap0, Content c |
2839+
exists(NodeEx mid, Typ t0, Ap ap0 |
28272840
pn1 = TStagePathNodeMid(mid, state, cc, summaryCtx, argT, argAp, t0, ap0) and
2828-
fwdFlowRead(t0, ap0, c, mid, node, state, cc, summaryCtx, argT, argAp) and
2841+
fwdFlowRead(t0, ap0, t, ap, _, mid, node, state, cc, summaryCtx, argT, argAp) and
28292842
label = ""
2830-
|
2831-
exists(NodeEx storeSource |
2832-
fwdFlowConsCandStoreReadMatchingEnabled(storeSource, t0, ap0, c, t, ap) and
2833-
storeMayReachReadInlineLate(storeSource, c, node)
2834-
)
2835-
or
2836-
fwdFlowConsCandStoreReadMatchingDisabled(t0, ap0, c, t, ap)
28372843
)
28382844
}
28392845

@@ -3421,28 +3427,20 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
34213427

34223428
private class NodeExAlias = NodeEx;
34233429

3424-
final private class ApaFinal = PrevStage::Ap;
3425-
34263430
private module StoreReadMatchingInput implements StoreReadMatchingInputSig {
34273431
class NodeEx = NodeExAlias;
34283432

3429-
class Ap extends ApaFinal {
3430-
Content getHead() { this = true and exists(result) }
3431-
}
3432-
3433-
predicate nodeApRange(NodeEx node, Ap ap) { PrevStage::revFlowAp(node, ap) }
3434-
34353433
predicate localValueStep(NodeEx node1, NodeEx node2) {
3436-
exists(FlowState state, Ap ap, PrevStage::ApOption returnAp |
3434+
exists(FlowState state, PrevStage::ApOption returnAp |
34373435
PrevStage::revFlow(node1, pragma[only_bind_into](state), _,
3438-
pragma[only_bind_into](returnAp), pragma[only_bind_into](ap)) and
3436+
pragma[only_bind_into](returnAp), true) and
34393437
PrevStage::revFlow(node2, pragma[only_bind_into](state), _,
3440-
pragma[only_bind_into](returnAp), pragma[only_bind_into](ap)) and
3438+
pragma[only_bind_into](returnAp), true) and
34413439
Stage2Param::localStep(node1, state, node2, state, true, _, _, _)
34423440
)
34433441
}
34443442

3445-
predicate jumpValueStep(NodeEx node1, NodeEx node2) { jumpStepEx(node1, node2) }
3443+
predicate jumpValueStep = jumpStepEx/2;
34463444

34473445
predicate callEdgeArgParam(NodeEx arg, NodeEx param) {
34483446
PrevStage::callEdgeArgParam(_, _, arg, param, true, _)
@@ -3452,15 +3450,13 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
34523450
PrevStage::callEdgeReturn(_, _, ret, _, out, true, _)
34533451
}
34543452

3455-
predicate readContentStep(NodeEx node1, Content c, NodeEx node2) {
3456-
PrevStage::readStepCand(node1, c, node2)
3457-
}
3453+
predicate readContentStep = PrevStage::readStepCand/3;
34583454

34593455
predicate storeContentStep(NodeEx node1, Content c, NodeEx node2) {
34603456
PrevStage::storeStepCand(node1, _, c, node2, _, _)
34613457
}
34623458

3463-
int accessPathConfigLimit() { result = Config::accessPathLimit() }
3459+
predicate accessPathConfigLimit = Config::accessPathLimit/0;
34643460
}
34653461

34663462
predicate storeMayReachRead = StoreReadMatching<StoreReadMatchingInput>::storeMayReachRead/3;

0 commit comments

Comments
 (0)