Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/PhasarLLVM/DataFlow/IfdsIde/LibCSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ using namespace psr::library_summary;
static library_summary::FunctionDataFlowFacts createLibCSummary() {
FunctionDataFlowFacts Sum;

Sum.addElement("atoi", 0, ReturnValue{});

// abs
Sum.addElement("abs", 0, ReturnValue{});

Expand Down
29 changes: 27 additions & 2 deletions lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ auto IFDSTaintAnalysis::getNormalFlowFunction(n_t Curr,
Gen.insert(Store->getValueOperand());
}

return lambdaFlow(
[Store, Gen{std::move(Gen)}](d_t Source) -> container_type {
auto Ret =
lambdaFlow([Store, Gen{std::move(Gen)}](d_t Source) -> container_type {
if (Store->getPointerOperand() == Source) {
return {};
}
Expand All @@ -291,6 +291,21 @@ auto IFDSTaintAnalysis::getNormalFlowFunction(n_t Curr,

return {Source};
});
if (Config->isSink(Store->getPointerOperand())) {
// Handle sink variables:

return lambdaFlow([this, Store, Ret = std::move(Ret)](d_t Source) {
if (Store->getValueOperand() == Source) {
if (Leaks[Store].insert(Source).second) {
Printer->onResult(Store, Source,
DataFlowAnalysisType::IFDSTaintAnalysis);
}
}

return Ret->computeTargets(Source);
});
}
return Ret;
}
// If a tainted value is loaded, the loaded value is of course tainted
if (const auto *Load = llvm::dyn_cast<llvm::LoadInst>(Curr)) {
Expand All @@ -316,6 +331,16 @@ auto IFDSTaintAnalysis::getNormalFlowFunction(n_t Curr,
return transferFlow(Cast, Cast->getOperand(0));
}

if (llvm::isa<llvm::BinaryOperator>(Curr)) {
return lambdaFlow([Curr](d_t Source) -> container_type {
if (llvm::is_contained(Curr->operand_values(), Source)) {
return {Source, Curr};
}

return {Source};
});
}

// Otherwise we do not care and leave everything as it is
return identityFlow();
}
Expand Down
Loading