svf-tools 1.0.716 → 1.0.718
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/MemoryModel/PointerAnalysis.h +0 -2
- package/svf/include/Util/SVFBugReport.h +4 -4
- package/svf/include/Util/SVFUtil.h +5 -0
- package/svf/lib/Graphs/VFG.cpp +3 -1
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +1 -14
- package/svf/lib/SABER/DoubleFreeChecker.cpp +1 -1
- package/svf/lib/SABER/FileChecker.cpp +2 -2
- package/svf/lib/SABER/LeakChecker.cpp +2 -2
- package/svf/lib/SABER/ProgSlice.cpp +4 -4
- package/svf/lib/Util/SVFBugReport.cpp +17 -17
- package/svf/lib/Util/SVFUtil.cpp +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.718",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -388,8 +388,6 @@ public:
|
|
|
388
388
|
|
|
389
389
|
/// Resolve indirect call edges
|
|
390
390
|
virtual void resolveIndCalls(const CallICFGNode* cs, const PointsTo& target, CallEdgeMap& newEdges);
|
|
391
|
-
/// Match arguments for callsite at caller and callee
|
|
392
|
-
bool matchArgs(const CallICFGNode* cs, const SVFFunction* callee);
|
|
393
391
|
|
|
394
392
|
/// CallGraph SCC related methods
|
|
395
393
|
//@{
|
|
@@ -48,7 +48,7 @@ namespace SVF
|
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
class
|
|
51
|
+
class SVFBugEvent
|
|
52
52
|
{
|
|
53
53
|
public:
|
|
54
54
|
enum EventType
|
|
@@ -65,8 +65,8 @@ protected:
|
|
|
65
65
|
const SVFInstruction *eventInst;
|
|
66
66
|
|
|
67
67
|
public:
|
|
68
|
-
|
|
69
|
-
virtual ~
|
|
68
|
+
SVFBugEvent(u32_t typeAndInfoFlag, const SVFInstruction *eventInst): typeAndInfoFlag(typeAndInfoFlag), eventInst(eventInst) { };
|
|
69
|
+
virtual ~SVFBugEvent() = default;
|
|
70
70
|
|
|
71
71
|
inline u32_t getEventType() const
|
|
72
72
|
{
|
|
@@ -80,7 +80,7 @@ public:
|
|
|
80
80
|
class GenericBug
|
|
81
81
|
{
|
|
82
82
|
public:
|
|
83
|
-
typedef std::vector<
|
|
83
|
+
typedef std::vector<SVFBugEvent> EventStack;
|
|
84
84
|
|
|
85
85
|
public:
|
|
86
86
|
enum BugType {FULLBUFOVERFLOW, PARTIALBUFOVERFLOW, NEVERFREE, PARTIALLEAK, DOUBLEFREE, FILENEVERCLOSE, FILEPARTIALCLOSE};
|
|
@@ -200,6 +200,11 @@ inline CallSite getSVFCallSite(const SVFInstruction* inst)
|
|
|
200
200
|
return cs;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
/// Match arguments for callsite at caller and callee
|
|
204
|
+
/// if the arg size does not match then we do not need to connect this parameter
|
|
205
|
+
/// unless the callee is a variadic function (the first parameter of variadic function is its paramter number)
|
|
206
|
+
bool matchArgs(const SVFInstruction* cs, const SVFFunction* callee);
|
|
207
|
+
|
|
203
208
|
/// Return LLVM callsite given a value
|
|
204
209
|
inline CallSite getSVFCallSite(const SVFValue* value)
|
|
205
210
|
{
|
package/svf/lib/Graphs/VFG.cpp
CHANGED
|
@@ -976,7 +976,8 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const SVFFun
|
|
|
976
976
|
CallSiteID csId = getCallSiteID(callBlockNode, callee);
|
|
977
977
|
RetICFGNode* retBlockNode = icfg->getRetICFGNode(callBlockNode->getCallSite());
|
|
978
978
|
// connect actual and formal param
|
|
979
|
-
if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee)
|
|
979
|
+
if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee) &&
|
|
980
|
+
matchArgs(callBlockNode->getCallSite(), callee))
|
|
980
981
|
{
|
|
981
982
|
const SVFIR::SVFVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
|
|
982
983
|
const SVFIR::SVFVarList& funArgList = pag->getFunArgsList(callee);
|
|
@@ -990,6 +991,7 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const SVFFun
|
|
|
990
991
|
connectAParamAndFParam(cs_arg, fun_arg, callBlockNode, csId, edges);
|
|
991
992
|
}
|
|
992
993
|
assert(funArgIt == funArgEit && "function has more arguments than call site");
|
|
994
|
+
|
|
993
995
|
if (callee->isVarArg())
|
|
994
996
|
{
|
|
995
997
|
NodeID varFunArg = pag->getVarargNode(callee);
|
|
@@ -408,9 +408,7 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta
|
|
|
408
408
|
const SVFFunction* calleefun = SVFUtil::cast<SVFFunction>(obj->getValue());
|
|
409
409
|
const SVFFunction* callee = calleefun->getDefFunForMultipleModule();
|
|
410
410
|
|
|
411
|
-
|
|
412
|
-
/// unless the callee is a variadic function (the first parameter of variadic function is its paramter number)
|
|
413
|
-
if(matchArgs(cs, callee) == false)
|
|
411
|
+
if(SVFUtil::matchArgs(cs->getCallSite(), callee) == false)
|
|
414
412
|
continue;
|
|
415
413
|
|
|
416
414
|
if(0 == getIndCallMap()[cs].count(callee))
|
|
@@ -429,17 +427,6 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta
|
|
|
429
427
|
}
|
|
430
428
|
}
|
|
431
429
|
|
|
432
|
-
/*!
|
|
433
|
-
* Match arguments for callsite at caller and callee
|
|
434
|
-
*/
|
|
435
|
-
bool PointerAnalysis::matchArgs(const CallICFGNode* cs, const SVFFunction* callee)
|
|
436
|
-
{
|
|
437
|
-
if(callee->isVarArg() || ThreadAPI::getThreadAPI()->isTDFork(cs->getCallSite()))
|
|
438
|
-
return true;
|
|
439
|
-
else
|
|
440
|
-
return SVFUtil::getSVFCallSite(cs->getCallSite()).arg_size() == callee->arg_size();
|
|
441
|
-
}
|
|
442
|
-
|
|
443
430
|
/*
|
|
444
431
|
* Get virtual functions "vfns" based on CHA
|
|
445
432
|
*/
|
|
@@ -42,7 +42,7 @@ void DoubleFreeChecker::reportBug(ProgSlice* slice)
|
|
|
42
42
|
GenericBug::EventStack eventStack;
|
|
43
43
|
slice->evalFinalCond2Event(eventStack);
|
|
44
44
|
eventStack.push_back(
|
|
45
|
-
|
|
45
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())->getCallSite()));
|
|
46
46
|
report.addSaberBug(GenericBug::DOUBLEFREE, eventStack);
|
|
47
47
|
}
|
|
48
48
|
if(Options::ValidateTests())
|
|
@@ -41,7 +41,7 @@ void FileChecker::reportBug(ProgSlice* slice)
|
|
|
41
41
|
// full leakage
|
|
42
42
|
GenericBug::EventStack eventStack =
|
|
43
43
|
{
|
|
44
|
-
|
|
44
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())->getCallSite())
|
|
45
45
|
};
|
|
46
46
|
report.addSaberBug(GenericBug::FILENEVERCLOSE, eventStack);
|
|
47
47
|
}
|
|
@@ -50,7 +50,7 @@ void FileChecker::reportBug(ProgSlice* slice)
|
|
|
50
50
|
GenericBug::EventStack eventStack;
|
|
51
51
|
slice->evalFinalCond2Event(eventStack);
|
|
52
52
|
eventStack.push_back(
|
|
53
|
-
|
|
53
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())->getCallSite()));
|
|
54
54
|
report.addSaberBug(GenericBug::FILEPARTIALCLOSE, eventStack);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -154,7 +154,7 @@ void LeakChecker::reportBug(ProgSlice* slice)
|
|
|
154
154
|
// full leakage
|
|
155
155
|
GenericBug::EventStack eventStack =
|
|
156
156
|
{
|
|
157
|
-
|
|
157
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())->getCallSite())
|
|
158
158
|
};
|
|
159
159
|
report.addSaberBug(GenericBug::NEVERFREE, eventStack);
|
|
160
160
|
}
|
|
@@ -164,7 +164,7 @@ void LeakChecker::reportBug(ProgSlice* slice)
|
|
|
164
164
|
GenericBug::EventStack eventStack;
|
|
165
165
|
slice->evalFinalCond2Event(eventStack);
|
|
166
166
|
eventStack.push_back(
|
|
167
|
-
|
|
167
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())->getCallSite()));
|
|
168
168
|
report.addSaberBug(GenericBug::PARTIALLEAK, eventStack);
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -153,11 +153,11 @@ void ProgSlice::evalFinalCond2Event(GenericBug::EventStack &eventStack) const
|
|
|
153
153
|
{
|
|
154
154
|
const SVFInstruction* tinst = pathAllocator->getCondInst(*it);
|
|
155
155
|
if(pathAllocator->isNegCond(*it))
|
|
156
|
-
eventStack.push_back(
|
|
157
|
-
|
|
156
|
+
eventStack.push_back(SVFBugEvent(
|
|
157
|
+
SVFBugEvent::Branch|((((u32_t)false) << 4) & BRANCHFLAGMASK), tinst));
|
|
158
158
|
else
|
|
159
|
-
eventStack.push_back(
|
|
160
|
-
|
|
159
|
+
eventStack.push_back(SVFBugEvent(
|
|
160
|
+
SVFBugEvent::Branch|((((u32_t)true) << 4) & BRANCHFLAGMASK), tinst));
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -37,15 +37,15 @@ using namespace SVF;
|
|
|
37
37
|
|
|
38
38
|
const std::string GenericBug::getLoc() const
|
|
39
39
|
{
|
|
40
|
-
const
|
|
41
|
-
assert(sourceInstEvent.getEventType() ==
|
|
40
|
+
const SVFBugEvent&sourceInstEvent = bugEventStack.at(bugEventStack.size() -1);
|
|
41
|
+
assert(sourceInstEvent.getEventType() == SVFBugEvent::SourceInst && "bugEventStack top should be a SourceInst event");
|
|
42
42
|
return sourceInstEvent.getEventLoc();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const std::string GenericBug::getFuncName() const
|
|
46
46
|
{
|
|
47
|
-
const
|
|
48
|
-
assert(sourceInstEvent.getEventType() ==
|
|
47
|
+
const SVFBugEvent&sourceInstEvent = bugEventStack.at(bugEventStack.size() -1);
|
|
48
|
+
assert(sourceInstEvent.getEventType() == SVFBugEvent::SourceInst && "bugEventStack top should be a SourceInst event");
|
|
49
49
|
return sourceInstEvent.getFuncName();
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -88,7 +88,7 @@ void BufferOverflowBug::printBugToTerminal() const
|
|
|
88
88
|
{
|
|
89
89
|
switch(event.getEventType())
|
|
90
90
|
{
|
|
91
|
-
case
|
|
91
|
+
case SVFBugEvent::CallSite:
|
|
92
92
|
{
|
|
93
93
|
SVFUtil::errs() << "\t\t callsite at : ( " << event.getEventLoc() << " )\n";
|
|
94
94
|
break;
|
|
@@ -239,21 +239,21 @@ void FilePartialCloseBug::printBugToTerminal() const
|
|
|
239
239
|
SVFUtil::errs() << "\n";
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
const std::string
|
|
242
|
+
const std::string SVFBugEvent::getFuncName() const
|
|
243
243
|
{
|
|
244
244
|
return eventInst->getFunction()->getName();
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
const std::string
|
|
247
|
+
const std::string SVFBugEvent::getEventLoc() const
|
|
248
248
|
{
|
|
249
249
|
return eventInst->getSourceLoc();
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
const std::string
|
|
252
|
+
const std::string SVFBugEvent::getEventDescription() const
|
|
253
253
|
{
|
|
254
254
|
switch(getEventType())
|
|
255
255
|
{
|
|
256
|
-
case
|
|
256
|
+
case SVFBugEvent::Branch:
|
|
257
257
|
{
|
|
258
258
|
if (typeAndInfoFlag & BRANCHFLAGMASK)
|
|
259
259
|
{
|
|
@@ -265,7 +265,7 @@ const std::string BugEvent::getEventDescription() const
|
|
|
265
265
|
}
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
|
-
case
|
|
268
|
+
case SVFBugEvent::CallSite:
|
|
269
269
|
{
|
|
270
270
|
std::string description("calls ");
|
|
271
271
|
const SVFFunction *callee = SVFUtil::getCallee(eventInst);
|
|
@@ -280,7 +280,7 @@ const std::string BugEvent::getEventDescription() const
|
|
|
280
280
|
return description;
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
|
-
case
|
|
283
|
+
case SVFBugEvent::SourceInst:
|
|
284
284
|
{
|
|
285
285
|
return "None";
|
|
286
286
|
}
|
|
@@ -303,10 +303,10 @@ void SVFBugReport::dumpToJsonFile(const std::string& filePath)
|
|
|
303
303
|
{
|
|
304
304
|
std::map<u32_t, std::string> eventType2Str =
|
|
305
305
|
{
|
|
306
|
-
{
|
|
307
|
-
{
|
|
308
|
-
{
|
|
309
|
-
{
|
|
306
|
+
{SVFBugEvent::CallSite, "call site"},
|
|
307
|
+
{SVFBugEvent::Caller, "caller"},
|
|
308
|
+
{SVFBugEvent::Loop, "loop"},
|
|
309
|
+
{SVFBugEvent::Branch, "branch"}
|
|
310
310
|
};
|
|
311
311
|
|
|
312
312
|
std::map<GenericBug::BugType, std::string> bugType2Str =
|
|
@@ -351,9 +351,9 @@ void SVFBugReport::dumpToJsonFile(const std::string& filePath)
|
|
|
351
351
|
if(BufferOverflowBug::classof(bugPtr))
|
|
352
352
|
{
|
|
353
353
|
// add only when bug is context sensitive
|
|
354
|
-
for(const
|
|
354
|
+
for(const SVFBugEvent&event : bugEventStack)
|
|
355
355
|
{
|
|
356
|
-
if (event.getEventType() ==
|
|
356
|
+
if (event.getEventType() == SVFBugEvent::SourceInst)
|
|
357
357
|
{
|
|
358
358
|
continue;
|
|
359
359
|
}
|
package/svf/lib/Util/SVFUtil.cpp
CHANGED
|
@@ -311,3 +311,16 @@ void SVFUtil::stopAnalysisLimitTimer(bool limitTimerSet)
|
|
|
311
311
|
{
|
|
312
312
|
if (limitTimerSet) alarm(0);
|
|
313
313
|
}
|
|
314
|
+
|
|
315
|
+
/// Match arguments for callsite at caller and callee
|
|
316
|
+
/// if the arg size does not match then we do not need to connect this parameter
|
|
317
|
+
/// unless the callee is a variadic function (the first parameter of variadic function is its paramter number)
|
|
318
|
+
/// e.g., void variadicFoo(int num, ...); variadicFoo(5, 1,2,3,4,5)
|
|
319
|
+
/// for variadic function, callsite arg size must be greater than or equal to callee arg size
|
|
320
|
+
bool SVFUtil::matchArgs(const SVFInstruction* cs, const SVFFunction* callee)
|
|
321
|
+
{
|
|
322
|
+
if (callee->isVarArg() || ThreadAPI::getThreadAPI()->isTDFork(cs))
|
|
323
|
+
return getSVFCallSite(cs).arg_size() >= callee->arg_size();
|
|
324
|
+
else
|
|
325
|
+
return getSVFCallSite(cs).arg_size() == callee->arg_size();
|
|
326
|
+
}
|