Skip to content

Commit d53beb3

Browse files
committed
JS: Embed check for in/out barriers in edge barrier check
1 parent 4964d81 commit d53beb3

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

javascript/ql/lib/semmle/javascript/dataflow/Configuration.qll

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ private BasicBlock getADominatedBasicBlock(BarrierGuardNode guard, ConditionGuar
514514
*
515515
* Only holds for barriers that should apply to all flow labels.
516516
*/
517-
private predicate isBarrierEdge(Configuration cfg, DataFlow::Node pred, DataFlow::Node succ) {
517+
private predicate isBarrierEdgeRaw(Configuration cfg, DataFlow::Node pred, DataFlow::Node succ) {
518518
cfg.isBarrierEdge(pred, succ)
519519
or
520520
exists(DataFlow::BarrierGuardNode guard |
@@ -523,11 +523,26 @@ private predicate isBarrierEdge(Configuration cfg, DataFlow::Node pred, DataFlow
523523
)
524524
}
525525

526+
/**
527+
* Holds if there is a barrier edge `pred -> succ` in `cfg` either through an explicit barrier edge
528+
* or one implied by a barrier guard, or by an out/in barrier for `pred` or `succ`, respectively.
529+
*
530+
* Only holds for barriers that should apply to all flow labels.
531+
*/
532+
pragma[inline]
533+
private predicate isBarrierEdge(Configuration cfg, DataFlow::Node pred, DataFlow::Node succ) {
534+
isBarrierEdgeRaw(cfg, pred, succ)
535+
or
536+
cfg.isBarrierOut(pred)
537+
or
538+
cfg.isBarrierIn(succ)
539+
}
540+
526541
/**
527542
* Holds if there is a labeled barrier edge `pred -> succ` in `cfg` either through an explicit barrier edge
528543
* or one implied by a barrier guard.
529544
*/
530-
private predicate isLabeledBarrierEdge(
545+
private predicate isLabeledBarrierEdgeRaw(
531546
Configuration cfg, DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel label
532547
) {
533548
cfg.isBarrierEdge(pred, succ, label)
@@ -538,6 +553,21 @@ private predicate isLabeledBarrierEdge(
538553
)
539554
}
540555

556+
/**
557+
* Holds if there is a labeled barrier edge `pred -> succ` in `cfg` either through an explicit barrier edge
558+
* or one implied by a barrier guard, or by an out/in barrier for `pred` or `succ`, respectively.
559+
*/
560+
pragma[inline]
561+
private predicate isLabeledBarrierEdge(
562+
Configuration cfg, DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel label
563+
) {
564+
isLabeledBarrierEdgeRaw(cfg, pred, succ, label)
565+
or
566+
cfg.isBarrierOut(pred, label)
567+
or
568+
cfg.isBarrierIn(succ, label)
569+
}
570+
541571
/**
542572
* A guard node that only blocks specific labels.
543573
*/

0 commit comments

Comments
 (0)