//Memory to Register Spreading void Tainter::spreadTaintRM(RegId reg, RegPart rp, TA_UINT addr) { if (rp == R_LOW || rp == R_HIGH) taintedRegs[reg][rp] = isTainted(addr); else for (short i = 0; i < rp; i++) taintedRegs[reg][i] = isTainted(addr + i); }
//Memory to Memory spreading void Tainter::spreadTaintMM(TA_UINT dstAddr, TA_UINT srcAddr, TA_UINT dataSize) { for (TA_UINT i = 0 ; i < dataSize; i++) if (isTainted(srcAddr + i)) taint(dstAddr + i); else untaint(dstAddr + i); }
std::list<TA_UINT> Tainter::getTaintedMem(TA_UINT begin, TA_UINT end) { std::list<TA_UINT> memlist; for (TA_UINT i = 0; i < end; i++) if (isTainted(i)) memlist.push_back(i); memlist.sort(); return memlist; }
bool DivergenceAnalysis::_promoteDivergentBranchesToConvergent( branch_set& branches) { bool removedDivergences = false; // Remove non-divergent branches from the set for (auto branch = branches.begin(); branch != branches.end(); ) { if (!isDivBranch(branch->instruction())) { report(" promoting " << branch->instruction().i->toString() << " to convergent."); const DataflowGraph::PhiInstructionVector& phis = branch->postDominator()->phis(); for (auto phi = phis.begin(); phi != phis.end(); ++phi) { DataflowGraph::RegisterVector::const_iterator source = phi->s.begin(); DataflowGraph::RegisterVector::const_iterator endSource = phi->s.end(); for (; source != endSource; source++) { if (branch->isTainted(source->id)) { report(" removing dependence r" << phi->d.id << " <- r" << branch->predicate()); _removePredicate(*phi, branch->predicate()); } } } _divergGraph.forceConvergent(branch->predicate()); removedDivergences = true; auto temp = branch++; branches.erase(temp); } else { ++branch; } } if (removedDivergences) { _divergGraph.computeDivergence(); } return removedDivergences; }
void Tainter::untaint(TA_UINT addr) { if (isTainted(addr)) taintedAddrs.remove(addr); }
void Tainter::taint(TA_UINT addr) { if (!isTainted(addr)) taintedAddrs.push_back(addr); }