Skip to content

Commit 38f8da8

Browse files
committed
update log format, added senapi keyword to branch cases
1 parent d2cbe97 commit 38f8da8

9 files changed

Lines changed: 490 additions & 753 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ endif()
3333

3434
# Compiler flags
3535
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall\
36-
-fdiagnostics-color=always -Wno-everything")
36+
-fdiagnostics-color=always")
3737

3838
include_directories("include")
3939
include_directories("src")

include/LockAttackAnalysis.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ namespace pdg
5353
void computeCorruptedCallBackRetVal();
5454
// semantic violation
5555
void computeBugOnLoc();
56-
void computeRiskyDirectRefCount();
57-
bool isAtomicRefCountCall(llvm::CallInst &CI);
56+
void computeRiskyDirectRefCount(nlohmann::ordered_json &riskyRefCJsons);
57+
bool isRefCountCall(llvm::CallInst &CI);
58+
bool isAtomicTRefCount(llvm::CallInst &CI);
59+
bool isRefCntTRefCount(llvm::CallInst &CI);
5860

5961
private:
6062
llvm::Module *_module;

include/PDGUtils.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace pdg
2727
bool hasReadAccess(llvm::Value &v);
2828
bool hasWriteAccess(llvm::Value &v);
2929
bool hasPtrDereference(llvm::Value &v);
30+
bool hasDoubleLoad(llvm::Value &v);
3031
bool isSentinelType(llvm::GlobalVariable &gv);
3132
bool isUserOfSentinelTypeVal(llvm::Value &v);
3233
bool isVoidPointerHasMultipleCasts(TreeNode &treeNode);
@@ -69,8 +70,10 @@ namespace pdg
6970
std::string getDemangledName(const char *mangledName);
7071
void readLinesFromFile(std::set<std::string> &lines, std::string fileName);
7172
void printSourceLocation(llvm::Instruction &I, llvm::raw_ostream &OutputStream = llvm::errs());
73+
unsigned getSourceLineNo(llvm::Instruction &I);
7274
std::string getSourceLocationStr(llvm::Instruction &I);
7375
std::string getSourceLocationStrForInlineInst(llvm::Instruction &I);
76+
std::string getInstructionString(llvm::Instruction &I);
7477
llvm::DILocation* getTopDebugLocation(llvm::DILocation *DL);
7578
std::string getFuncSourceLocStr(llvm::Function &F);
7679
unsigned getFuncUniqueId(const llvm::Function &F);

include/RiskyAPIAnalysis.hh

Lines changed: 0 additions & 63 deletions
This file was deleted.

include/RiskyFieldAnalysis.hh

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,19 @@ namespace pdg
1414
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
1515
llvm::StringRef getPassName() const override { return "Risky Field Analysis"; }
1616
bool runOnModule(llvm::Module &M) override;
17+
void propagateTaints(std::set<llvm::Function *> &kernelInterfaceAPIs);
18+
void classifyRiskySharedFields();
19+
void classifyRiskyBoundaryParams(std::set<llvm::Function *> &kernelInterfaceAPIs);
20+
void classifyDrvCallBackRetval();
21+
1722
bool isDriverControlledField(TreeNode &tn);
1823
llvm::Function *canReachSensitiveOperations(Node &srcFuncNode);
1924
void classifyRiskyFieldDirectUse(TreeNode &tn);
2025
void classifyRiskyFieldTaint(TreeNode &tn);
21-
void classifyRiskyField(TreeNode &tn, std::set<RiskyDataType> &riskyClassifications, nlohmann::ordered_json &taintJsonObjs, unsigned &caseID);
22-
bool classifyRiskyPtrField(TreeNode &tn, std::set<RiskyDataType> &riskyClassifications, nlohmann::ordered_json &taintJsonObjs, unsigned &caseID);
23-
bool classifyRiskyNonPtrField(TreeNode &tn, std::set<RiskyDataType> &riskyClassifications, nlohmann::ordered_json &taintJsonObjs, unsigned &caseID);
24-
// checks for atomic_t type field
25-
bool isSharedAtomicField(TreeNode &tn);
26-
27-
// pointer field checks
28-
bool checkPtrValUsedInPtrArithOp(Node &n);
29-
// scalar field checks
30-
bool checkValUsedAsArrayIndex(Node &n);
31-
bool checkIsArrayAccess(llvm::Instruction &inst);
32-
// generic field checks
33-
static bool checkValUsedInPtrArithOp(Node &n);
34-
bool checkValUsedInSenBranchCond(Node &n, llvm::raw_fd_ostream &OS, std::string &senTypeStr);
35-
bool checkValInSecurityChecks(Node &n);
36-
static bool checkValUsedInSensitiveOperations(Node &n, std::string &senOpName);
37-
bool checkValUsedInInlineAsm(Node &n);
38-
bool isSensitiveOperation(llvm::Function &F);
26+
void classifyRiskyField(TreeNode &tn, std::set<RiskyDataType> &riskyClassifications, nlohmann::ordered_json &taintJsonObjs);
27+
bool classifyRiskyPtrField(TreeNode &tn, std::set<RiskyDataType> &riskyClassifications, nlohmann::ordered_json &taintJsonObjs);
28+
bool classifyRiskyNonPtrField(TreeNode &tn, std::set<RiskyDataType> &riskyClassifications, nlohmann::ordered_json &taintJsonObjs);
29+
// helper funcs
3930
bool hasUpdateInDrv(TreeNode &n);
4031
// print helpers
4132
void printRiskyFieldInfo(llvm::raw_ostream &os, const std::string &category, TreeNode &treeNode, llvm::Function &func, llvm::Instruction &inst);
@@ -58,6 +49,7 @@ namespace pdg
5849
// store taint source/sink pair
5950
std::set<std::tuple<Node *, Node *, std::string, std::string>> _taintTuples;
6051
std::set<std::tuple<Node *, Node *, std::string, std::string>> _structTaintTuples; // used to store taint for struct field
52+
unsigned _caseID = 0;
6153
// stats counting
6254
unsigned _numKernelReadDriverUpdatedFields = 0;
6355
unsigned _numSharedFields = 0;
@@ -72,7 +64,6 @@ namespace pdg
7264
std::unordered_map<RiskyDataType, int> totalRiskyFieldCounters;
7365
std::unordered_map<RiskyDataType, int> totalRiskyParamCounters;
7466
nlohmann::ordered_json taintTracesJson = nlohmann::ordered_json::array();
75-
nlohmann::ordered_json taintTracesJsonNoConds = nlohmann::ordered_json::array();
7667
nlohmann::ordered_json unclassifiedFieldsJson = nlohmann::ordered_json::array();
7768
};
7869
}

0 commit comments

Comments
 (0)