@@ -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