|
|
|
|
@@ -2275,7 +2275,7 @@ private predicate guardControlsPhiInput(
|
|
|
|
|
*/
|
|
|
|
|
signature predicate guardChecksSig(IRGuardCondition g, Expr e, boolean branch);
|
|
|
|
|
|
|
|
|
|
bindingset[g, n]
|
|
|
|
|
bindingset[g]
|
|
|
|
|
pragma[inline_late]
|
|
|
|
|
private predicate controls(IRGuardCondition g, Node n, boolean edge) {
|
|
|
|
|
g.controls(n.getBasicBlock(), edge)
|
|
|
|
|
@@ -2288,6 +2288,15 @@ private predicate controls(IRGuardCondition g, Node n, boolean edge) {
|
|
|
|
|
* in data flow and taint tracking.
|
|
|
|
|
*/
|
|
|
|
|
module BarrierGuard<guardChecksSig/3 guardChecks> {
|
|
|
|
|
bindingset[value, n]
|
|
|
|
|
pragma[inline_late]
|
|
|
|
|
private predicate convertedExprHasValueNumber(ValueNumber value, Node n) {
|
|
|
|
|
exists(Expr e |
|
|
|
|
|
e = value.getAnInstruction().getConvertedResultExpression() and
|
|
|
|
|
n.asConvertedExpr() = e
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets an expression node that is safely guarded by the given guard check.
|
|
|
|
|
*
|
|
|
|
|
@@ -2321,9 +2330,8 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
|
|
|
|
|
* NOTE: If an indirect expression is tracked, use `getAnIndirectBarrierNode` instead.
|
|
|
|
|
*/
|
|
|
|
|
Node getABarrierNode() {
|
|
|
|
|
exists(IRGuardCondition g, Expr e, ValueNumber value, boolean edge |
|
|
|
|
|
e = value.getAnInstruction().getConvertedResultExpression() and
|
|
|
|
|
result.asConvertedExpr() = e and
|
|
|
|
|
exists(IRGuardCondition g, ValueNumber value, boolean edge |
|
|
|
|
|
convertedExprHasValueNumber(value, result) and
|
|
|
|
|
guardChecks(g,
|
|
|
|
|
pragma[only_bind_into](value.getAnInstruction().getConvertedResultExpression()), edge) and
|
|
|
|
|
controls(g, result, edge)
|
|
|
|
|
@@ -2374,6 +2382,17 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
|
|
|
|
|
*/
|
|
|
|
|
Node getAnIndirectBarrierNode() { result = getAnIndirectBarrierNode(_) }
|
|
|
|
|
|
|
|
|
|
bindingset[value, n]
|
|
|
|
|
pragma[inline_late]
|
|
|
|
|
private predicate indirectConvertedExprHasValueNumber(
|
|
|
|
|
int indirectionIndex, ValueNumber value, Node n
|
|
|
|
|
) {
|
|
|
|
|
exists(Expr e |
|
|
|
|
|
e = value.getAnInstruction().getConvertedResultExpression() and
|
|
|
|
|
n.asIndirectConvertedExpr(indirectionIndex) = e
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets an indirect expression node with indirection index `indirectionIndex` that is
|
|
|
|
|
* safely guarded by the given guard check.
|
|
|
|
|
@@ -2409,9 +2428,8 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
|
|
|
|
|
* NOTE: If a non-indirect expression is tracked, use `getABarrierNode` instead.
|
|
|
|
|
*/
|
|
|
|
|
Node getAnIndirectBarrierNode(int indirectionIndex) {
|
|
|
|
|
exists(IRGuardCondition g, Expr e, ValueNumber value, boolean edge |
|
|
|
|
|
e = value.getAnInstruction().getConvertedResultExpression() and
|
|
|
|
|
result.asIndirectConvertedExpr(indirectionIndex) = e and
|
|
|
|
|
exists(IRGuardCondition g, ValueNumber value, boolean edge |
|
|
|
|
|
indirectConvertedExprHasValueNumber(indirectionIndex, value, result) and
|
|
|
|
|
guardChecks(g,
|
|
|
|
|
pragma[only_bind_into](value.getAnInstruction().getConvertedResultExpression()), edge) and
|
|
|
|
|
controls(g, result, edge)
|
|
|
|
|
@@ -2450,12 +2468,20 @@ private EdgeKind getConditionalEdge(boolean branch) {
|
|
|
|
|
* in data flow and taint tracking.
|
|
|
|
|
*/
|
|
|
|
|
module InstructionBarrierGuard<instructionGuardChecksSig/3 instructionGuardChecks> {
|
|
|
|
|
bindingset[value, n]
|
|
|
|
|
pragma[inline_late]
|
|
|
|
|
private predicate operandHasValueNumber(ValueNumber value, Node n) {
|
|
|
|
|
exists(Operand use |
|
|
|
|
|
use = value.getAnInstruction().getAUse() and
|
|
|
|
|
n.asOperand() = use
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Gets a node that is safely guarded by the given guard check. */
|
|
|
|
|
Node getABarrierNode() {
|
|
|
|
|
exists(IRGuardCondition g, ValueNumber value, boolean edge, Operand use |
|
|
|
|
|
exists(IRGuardCondition g, ValueNumber value, boolean edge |
|
|
|
|
|
instructionGuardChecks(g, pragma[only_bind_into](value.getAnInstruction()), edge) and
|
|
|
|
|
use = value.getAnInstruction().getAUse() and
|
|
|
|
|
result.asOperand() = use and
|
|
|
|
|
operandHasValueNumber(value, result) and
|
|
|
|
|
controls(g, result, edge)
|
|
|
|
|
)
|
|
|
|
|
or
|
|
|
|
|
|