svf-tools 1.0.973 → 1.0.975
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/AE/Core/AbstractState.h +18 -11
- package/svf/include/AE/Svfexe/AbstractInterpretation.h +46 -33
- package/svf/include/AE/Svfexe/BufOverflowChecker.h +17 -6
- package/svf/include/AE/Svfexe/ICFGSimplification.h +0 -1
- package/svf/include/Graphs/WTO.h +4 -4
- package/svf/lib/AE/Core/AbstractState.cpp +309 -54
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +759 -247
- package/svf/lib/AE/Svfexe/BufOverflowChecker.cpp +27 -37
- package/svf/lib/AE/Svfexe/ICFGSimplification.cpp +1 -0
- package/svf-llvm/tools/AE/ae.cpp +15 -1
- package/svf-llvm/tools/Example/svf-ex.cpp +1 -66
- package/svf/include/AE/Svfexe/SVFIR2AbsState.h +0 -191
- package/svf/lib/AE/Svfexe/SVFIR2AbsState.cpp +0 -957
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.975",
|
|
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": {
|
|
@@ -46,8 +46,9 @@
|
|
|
46
46
|
#ifndef Z3_EXAMPLE_INTERVAL_DOMAIN_H
|
|
47
47
|
#define Z3_EXAMPLE_INTERVAL_DOMAIN_H
|
|
48
48
|
|
|
49
|
-
#include "AE/Core/IntervalValue.h"
|
|
50
49
|
#include "AE/Core/AbstractValue.h"
|
|
50
|
+
#include "AE/Core/IntervalValue.h"
|
|
51
|
+
#include "SVFIR/SVFVariables.h"
|
|
51
52
|
#include "Util/Z3Expr.h"
|
|
52
53
|
|
|
53
54
|
#include <iomanip>
|
|
@@ -79,6 +80,21 @@ public:
|
|
|
79
80
|
|
|
80
81
|
virtual ~AbstractState() = default;
|
|
81
82
|
|
|
83
|
+
// getGepObjAddrs
|
|
84
|
+
AddressValue getGepObjAddrs(u32_t pointer, IntervalValue offset);
|
|
85
|
+
|
|
86
|
+
// initObjVar
|
|
87
|
+
void initObjVar(ObjVar* objVar);
|
|
88
|
+
// getElementIndex
|
|
89
|
+
IntervalValue getElementIndex(const GepStmt* gep);
|
|
90
|
+
// getByteOffset
|
|
91
|
+
IntervalValue getByteOffset(const GepStmt* gep);
|
|
92
|
+
// printAbstractState
|
|
93
|
+
// loadValue
|
|
94
|
+
AbstractValue loadValue(NodeID varId);
|
|
95
|
+
// storeValue
|
|
96
|
+
void storeValue(NodeID varId, AbstractValue val);
|
|
97
|
+
|
|
82
98
|
|
|
83
99
|
/// The physical address starts with 0x7f...... + idx
|
|
84
100
|
static inline u32_t getVirtualMemAddress(u32_t idx)
|
|
@@ -258,14 +274,9 @@ public:
|
|
|
258
274
|
/// domain narrow with other, and return the narrowed domain
|
|
259
275
|
AbstractState narrowing(const AbstractState&other);
|
|
260
276
|
|
|
261
|
-
/// domain widen with other, important! other widen this.
|
|
262
|
-
void widenWith(const AbstractState&other);
|
|
263
|
-
|
|
264
277
|
/// domain join with other, important! other widen this.
|
|
265
278
|
void joinWith(const AbstractState&other);
|
|
266
279
|
|
|
267
|
-
/// domain narrow with other, important! other widen this.
|
|
268
|
-
void narrowWith(const AbstractState&other);
|
|
269
280
|
|
|
270
281
|
/// domain meet with other, important! other widen this.
|
|
271
282
|
void meetWith(const AbstractState&other);
|
|
@@ -299,8 +310,7 @@ public:
|
|
|
299
310
|
}
|
|
300
311
|
|
|
301
312
|
|
|
302
|
-
|
|
303
|
-
void printExprValues(std::ostream &oss) const;
|
|
313
|
+
void printAbstractState() const;
|
|
304
314
|
|
|
305
315
|
std::string toString() const
|
|
306
316
|
{
|
|
@@ -386,9 +396,6 @@ public:
|
|
|
386
396
|
}
|
|
387
397
|
|
|
388
398
|
|
|
389
|
-
protected:
|
|
390
|
-
void printTable(const VarToAbsValMap&table, std::ostream &oss) const;
|
|
391
|
-
|
|
392
399
|
};
|
|
393
400
|
|
|
394
401
|
}
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
//
|
|
30
30
|
|
|
31
31
|
#include "AE/Core/ICFGWTO.h"
|
|
32
|
-
#include "AE/Svfexe/SVFIR2AbsState.h"
|
|
33
32
|
#include "Util/SVFBugReport.h"
|
|
34
33
|
#include "WPA/Andersen.h"
|
|
34
|
+
#include "AE/Core/AbstractState.h"
|
|
35
35
|
|
|
36
36
|
namespace SVF
|
|
37
37
|
{
|
|
@@ -137,16 +137,16 @@ protected:
|
|
|
137
137
|
/// Global ICFGNode is handled at the entry of the program,
|
|
138
138
|
virtual void handleGlobalNode();
|
|
139
139
|
|
|
140
|
-
///
|
|
141
|
-
void
|
|
140
|
+
/// Mark recursive functions in the call graph
|
|
141
|
+
void initWTO();
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Check if execution state exist by merging states of predecessor nodes
|
|
145
145
|
*
|
|
146
|
-
* @param
|
|
146
|
+
* @param icfgNode The icfg node to analyse
|
|
147
147
|
* @return if this node has preceding execution state
|
|
148
148
|
*/
|
|
149
|
-
bool
|
|
149
|
+
bool mergeStatesFromPredecessors(const ICFGNode * icfgNode);
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Check if execution state exist at the branch edge
|
|
@@ -161,14 +161,7 @@ protected:
|
|
|
161
161
|
*
|
|
162
162
|
* @param block basic block that has one instruction or a series of instructions
|
|
163
163
|
*/
|
|
164
|
-
virtual void
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* handle one instruction in ICFGNode
|
|
168
|
-
*
|
|
169
|
-
* @param node ICFGNode which has a single instruction
|
|
170
|
-
*/
|
|
171
|
-
virtual void handleICFGNode(const ICFGNode* node);
|
|
164
|
+
virtual void handleSingletonWTO(const ICFGSingletonWTO *icfgSingletonWto);
|
|
172
165
|
|
|
173
166
|
/**
|
|
174
167
|
* handle call node in ICFGNode
|
|
@@ -182,14 +175,12 @@ protected:
|
|
|
182
175
|
*
|
|
183
176
|
* @param cycle WTOCycle which has weak topo order of basic blocks and nested cycles
|
|
184
177
|
*/
|
|
185
|
-
virtual void
|
|
178
|
+
virtual void handleCycleWTO(const ICFGCycleWTO* cycle);
|
|
179
|
+
|
|
180
|
+
void handleWTOComponents(const std::list<const ICFGWTOComp*>& wtoComps);
|
|
181
|
+
|
|
182
|
+
void handleWTOComponent(const ICFGWTOComp* wtoComp);
|
|
186
183
|
|
|
187
|
-
/**
|
|
188
|
-
* handle user defined function, ext function is not included.
|
|
189
|
-
*
|
|
190
|
-
* @param func SVFFunction which has a series of basic blocks
|
|
191
|
-
*/
|
|
192
|
-
virtual void handleFunc(const SVFFunction* func);
|
|
193
184
|
|
|
194
185
|
/**
|
|
195
186
|
* handle SVF Statement like CmpStmt, CallStmt, GepStmt, LoadStmt, StoreStmt, etc.
|
|
@@ -332,11 +323,34 @@ protected:
|
|
|
332
323
|
void AccessMemoryViaCallArgs(const SVF::SVFArgument *arg, SVF::FILOWorkList<const SVFValue *>& worklist, Set<const SVFValue *>& visited);
|
|
333
324
|
|
|
334
325
|
|
|
326
|
+
void updateStateOnAddr(const AddrStmt *addr);
|
|
327
|
+
|
|
328
|
+
void updateStateOnBinary(const BinaryOPStmt *binary);
|
|
329
|
+
|
|
330
|
+
void updateStateOnCmp(const CmpStmt *cmp);
|
|
331
|
+
|
|
332
|
+
void updateStateOnLoad(const LoadStmt *load);
|
|
333
|
+
|
|
334
|
+
void updateStateOnStore(const StoreStmt *store);
|
|
335
|
+
|
|
336
|
+
void updateStateOnCopy(const CopyStmt *copy);
|
|
337
|
+
|
|
338
|
+
void updateStateOnCall(const CallPE *callPE);
|
|
339
|
+
|
|
340
|
+
void updateStateOnRet(const RetPE *retPE);
|
|
341
|
+
|
|
342
|
+
void updateStateOnGep(const GepStmt *gep);
|
|
343
|
+
|
|
344
|
+
void updateStateOnSelect(const SelectStmt *select);
|
|
345
|
+
|
|
346
|
+
void updateStateOnPhi(const PhiStmt *phi);
|
|
347
|
+
|
|
348
|
+
IntervalValue getRangeLimitFromType(const SVFType* type);
|
|
349
|
+
|
|
350
|
+
|
|
335
351
|
/// protected data members, also used in subclasses
|
|
336
352
|
SVFIR* _svfir;
|
|
337
|
-
PTACallGraph* _callgraph;
|
|
338
353
|
/// Execution State, used to store the Interval Value of every SVF variable
|
|
339
|
-
SVFIR2AbsState* _svfir2AbsState;
|
|
340
354
|
AEAPI* _api{nullptr};
|
|
341
355
|
|
|
342
356
|
ICFG* _icfg;
|
|
@@ -347,7 +361,6 @@ protected:
|
|
|
347
361
|
SVFBugReport _recoder;
|
|
348
362
|
std::vector<const CallICFGNode*> _callSiteStack;
|
|
349
363
|
Map<const ICFGNode*, std::string> _nodeToBugInfo;
|
|
350
|
-
AndersenWaveDiff* _ander;
|
|
351
364
|
Map<const SVFFunction*, ICFGWTO*> _funcToWTO;
|
|
352
365
|
Set<const SVFFunction*> _recursiveFuns;
|
|
353
366
|
|
|
@@ -363,32 +376,32 @@ private:
|
|
|
363
376
|
virtual void indirectCallFunPass(const CallICFGNode* callNode);
|
|
364
377
|
|
|
365
378
|
protected:
|
|
366
|
-
// helper functions in handleCycle
|
|
367
|
-
bool isFixPointAfterWidening(const ICFGNode* cycle_head,
|
|
368
|
-
AbstractState& pre_as);
|
|
369
|
-
bool isFixPointAfterNarrowing(const SVF::ICFGNode* cycle_head,
|
|
370
|
-
SVF::AbstractState& pre_as);
|
|
371
379
|
|
|
372
|
-
AbstractState&
|
|
380
|
+
AbstractState& getAbsStateFromTrace(const ICFGNode* node)
|
|
373
381
|
{
|
|
374
382
|
const ICFGNode* repNode = _icfg->getRepNode(node);
|
|
375
|
-
if (
|
|
383
|
+
if (_abstractTrace.count(repNode) == 0)
|
|
376
384
|
{
|
|
377
385
|
assert(0 && "No preAbsTrace for this node");
|
|
378
386
|
}
|
|
379
387
|
else
|
|
380
388
|
{
|
|
381
|
-
return
|
|
389
|
+
return _abstractTrace[repNode];
|
|
382
390
|
}
|
|
383
391
|
}
|
|
384
392
|
|
|
393
|
+
bool hasAbsStateFromTrace(const ICFGNode* node)
|
|
394
|
+
{
|
|
395
|
+
const ICFGNode* repNode = _icfg->getRepNode(node);
|
|
396
|
+
return _abstractTrace.count(repNode) != 0;
|
|
397
|
+
}
|
|
398
|
+
|
|
385
399
|
protected:
|
|
386
400
|
// there data should be shared with subclasses
|
|
387
401
|
Map<std::string, std::function<void(const CallSite &)>> _func_map;
|
|
388
402
|
Set<const CallICFGNode*> _checkpoints;
|
|
389
403
|
Set<std::string> _checkpoint_names;
|
|
390
|
-
Map<const ICFGNode*, AbstractState>
|
|
391
|
-
Map<const ICFGNode*, AbstractState> _postAbsTrace;
|
|
404
|
+
Map<const ICFGNode*, AbstractState> _abstractTrace; // abstract states immediately after nodes
|
|
392
405
|
std::string _moduleName;
|
|
393
406
|
};
|
|
394
407
|
}
|
|
@@ -174,12 +174,23 @@ private:
|
|
|
174
174
|
*/
|
|
175
175
|
virtual void handleSVFStatement(const SVFStmt *stmt) override;
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
177
|
+
// TODO: will delete later
|
|
178
|
+
virtual void handleSingletonWTO(const ICFGSingletonWTO *icfgSingletonWto) override
|
|
179
|
+
{
|
|
180
|
+
AbstractInterpretation::handleSingletonWTO(icfgSingletonWto);
|
|
181
|
+
const ICFGNode* repNode = _icfg->getRepNode(icfgSingletonWto->getICFGNode());
|
|
182
|
+
if (_abstractTrace.count(repNode) == 0)
|
|
183
|
+
{
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const std::vector<const ICFGNode*>& worklist_vec = _icfg->getSubNodes(icfgSingletonWto->getICFGNode());
|
|
187
|
+
|
|
188
|
+
for (auto it = worklist_vec.begin(); it != worklist_vec.end(); ++it)
|
|
189
|
+
{
|
|
190
|
+
const ICFGNode* curNode = *it;
|
|
191
|
+
detectBufOverflow(curNode);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
183
194
|
|
|
184
195
|
/**
|
|
185
196
|
* check buffer overflow at ICFGNode which is a checkpoint
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
// The implementation is based on
|
|
28
28
|
// Xiao Cheng, Jiawei Wang and Yulei Sui. Precise Sparse Abstract Execution via Cross-Domain Interaction.
|
|
29
29
|
// 46th International Conference on Software Engineering. (ICSE24)
|
|
30
|
-
#include "AE/Svfexe/SVFIR2AbsState.h"
|
|
31
30
|
#include "Graphs/ICFG.h"
|
|
32
31
|
|
|
33
32
|
namespace SVF
|
package/svf/include/Graphs/WTO.h
CHANGED
|
@@ -341,7 +341,7 @@ public:
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
/// Return the graph node
|
|
344
|
-
const NodeT*
|
|
344
|
+
const NodeT* getICFGNode() const
|
|
345
345
|
{
|
|
346
346
|
return _node;
|
|
347
347
|
}
|
|
@@ -457,7 +457,7 @@ public:
|
|
|
457
457
|
std::string str;
|
|
458
458
|
std::stringstream rawstr(str);
|
|
459
459
|
rawstr << "(";
|
|
460
|
-
rawstr << _head->
|
|
460
|
+
rawstr << _head->getICFGNode()->getId() << ", ";
|
|
461
461
|
for (auto it = begin(), et = end(); it != et;)
|
|
462
462
|
{
|
|
463
463
|
rawstr << (*it)->toString();
|
|
@@ -698,7 +698,7 @@ protected:
|
|
|
698
698
|
|
|
699
699
|
void visit(const WTOCycleT& cycle) override
|
|
700
700
|
{
|
|
701
|
-
const NodeT* head = cycle.head()->
|
|
701
|
+
const NodeT* head = cycle.head()->getICFGNode();
|
|
702
702
|
WTOCycleDepthPtr previous_cycleDepth = _wtoCycleDepth;
|
|
703
703
|
_nodeToWTOCycleDepth.insert(std::make_pair(head, _wtoCycleDepth));
|
|
704
704
|
_wtoCycleDepth =
|
|
@@ -714,7 +714,7 @@ protected:
|
|
|
714
714
|
void visit(const WTONodeT& node) override
|
|
715
715
|
{
|
|
716
716
|
_nodeToWTOCycleDepth.insert(
|
|
717
|
-
std::make_pair(node.
|
|
717
|
+
std::make_pair(node.getICFGNode(), _wtoCycleDepth));
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
}; // end class WTOCycleDepthBuilder
|