付费下载
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Bug SearchXU, Hui August 31, 2022COMP130159.01MotivationBugs have similar patternsIf rules can be extracted:Search possible bugs based on rulesTypical cases are related to exception handlingOtherwiseSearch possible bugs based on a bug repositorySimilarity-based approachBug Avoidance ApproachesBug Av
2、oidanceDynamic analysis Static analysis Search Rule-basedSimilarity-basedCompiler techniquesType checkingAbstract interpretationTestingSymbolic executionFuzzing1. Rule-based ApproachError HandlingIn error handling paths, the driver should release the acquired resources and execute the operations tha
3、t are opposite to its previous execution.Bugs occur if developers forget/fail to handle the errors properly. Liu, Huqiu, et al. PF-Miner: A new paired functions mining method for Android kernel in error paths. ACSAC 2014.An Example 1. request memory (successful)3. return without memory release2. ior
4、emap (fail), goto outA bug found in Android kernel 3.10.0: drivers/ide/au1xxx-ide.cPaired Function MiningSome functions should be used pairwise, e.g.,pci_ioremap, pci_iounmappci_enable_device, pci_disable_deviceBasic idea of PF-Miner:Find paired functions of a target project.Assuming paired function
5、s are unknown in advance.Otherwise, a dictionary of paired functions can be employed. Label paired functions on the control-flow graph;Detect violations by checking all control flows.Liu, Huqiu, et al. PF-Miner: A new paired functions mining method for Android kernel in error paths. ACSAC 2014.How t
6、o Detect Paired Functions?Host FunctionCallee 1Callee 2Callee nStep 1: classify callees into two sets based on their context:Callees of normal paths;Callees of exception paths.Step 2: find paires of callees between the two sets.Find Possible Paired CalleesCallees of normal pathspci_enable_device()pc
7、i_request_regions()pci_iomap()Callees of exception pathspci_disable_device()pci_release_regions() pc_enable_device()pci_request_regions()pci_iomap()pci_disable_device()pci_releason_regions()pci_disable_device() failsuccessfulfailsuccessfulfailsuccessfulEvaluate If Two Callees Can Be PairedPaired fun
8、ctions should operate on the same resource in an opposite manner, e.g., by splitting the identifier of pci_enable_device() and pci_disable_device()Resource: pci_deviceOpposite operation: enable, disableDetect Violationsrequest_mem_region()ioremap()outfailsuccessfulsuccessfulfailViolation condition (
9、no resource release): a route with only one of the paired function that is successfully executed.EvaluationAndroid kernel version 2.6.39 (forked from Linux).81 bugs reported by PF-Miner (all fixed in 3.10.0)26 paired functions50 driversAndroid kernel 3.10.0983 violations from 4225 driversTop 51 are
10、potential bugsNeed to confirm with developers.546 paired functions3. Similarity-based ApproachCode SimilarityTo measure how much two code snippets/functions are alike or different from each other.“Hello World” Compiled with GCC“Hello World” Compiled with Clangpush rbpmov rbp, rsplea rdi, s; Hello Wo
11、rldcall _putsmov eax, 0pop rbpretnvar_8= dword ptr -8var_4= dword ptr -4push rbpmov rbp, rspsub rsp, 10hmov rdi, offset format ; Hello Worldnmov rbp+var_4, 0mov al, 0call _printfxor ecx, ecxmov rbp+var_8, eaxmov eax, ecxadd rsp, 10hpop rbpretnPreliminary Features in BinDiffFunction Matchinghash matc
12、hingname hash matchingaddressstring referencesloop countcall sequenceBasic Block Matchinghash matchingcall reference matchingstring reference matching Problem Definition and IdeasIdea 1:Locate suspicious code snippets, and then compare the similarityPairwise Graph MatchingIdea 2:Create an embedding
13、for each bug (codebook), and then search similar embeddings Graph EmbeddingBug Repobug code 1bug code 2bug code nSearchProblem: searching bugs with a set of bug samples as conditions, which is more difficult than searching documents.Pairwise Graph MatchingStep 1: compute the distance between each ba
14、sic-block pair of Graph-A and Graph-BGenerate a block distance matrixStep 2: match Graph-A and Graph-BBipartite matchingMaximum common subgraphCFG Matching as Bipartite MatchingA1A2A3A4B1B2B3B5B4A1A3A2A4B1B2B3B4B5VSVSA5A5Block Similarity: Edit DistanceRemove the variables/constants of each instructi
15、onCompute edit distanceLongest common subsequence (LCS) distance: allow only insertion and deletion, not substitution.Levenshtein distance: allow deletion, insertion and substitution.push eaxlea eax, esp+11Ch+var_108push eaxcall sub_404F5Elea ecx, esp+118h+var_F0call ds:_imp_?1?$CStringTDCmmUAEXZmov
16、 esi, edi+18hmov edi, edicmp esp+118h+var_108, ebxjz short loc_408D5Fpushlea pushcallleacallmovmovcmpjzstemFind the Longest Common Subsequence pushmovsubmovmovmovcallxormovmovaddpopretnpushmovleacallmovpopretn/sample solution with dynamic programming /a is a sequence with i instructions/b is a seque
17、nce with j instructionsLCS(a,b,i,j) if (i = 0 or j = 0) return 0; if (ai = bj) return LCS(a,b,i-1,j-1)+1 else return max(LCS(a,b,i-1,j),LCS(a,b,i,j-1)Use the length of the longest common subsequence for distance calculation, e.g.,Weighted Bipartite Graph MatchingA1A2A3A4B1B2B3B4Code ACode BB5A5Kuhn-
18、Munkres Algorithm (Matrix View)CostB1B2B3A10.20.350.40A20.400.100.20A30.150.200.70 Hungarian Maximum Matching AlgorithmStep 3: subtract the smallest value in each column from all other values in the column Step 1: Initiate adjacent matrixStep 2: Subtract the smallest value in each row from the other
19、 values in the rowCostB1B2B3A100.150.20A20.30 0 0.10A300.050.55 CostB1B2B3A100.150.10A20.30 0 0A300.050.45 Step 4: Draw lines through the row and columns that have the 0 entries such that the fewest lines possible are drawn. CostB1B2B3A100.150.10A20.30 0 0A300.050.45 Kuhn-Munkres Algorithm (Matrix V
20、iew)Hungarian Maximum Matching AlgorithmStep 5: If there are n lines drawn, an optimal assignment of zeros is possible and the algorithm is finished. If the number of lines is less than n, then the optimal number of zeroes is not yet reached. Go to the next step.CostB1B2B3A100.150.10A20.30 0 0A300.0
21、50.45 CostB1B2B3A100.100.5A20.30 0 0A3000.40 Step 6: Find the smallest entry not covered by any line. Subtract this entry from each row that isnt crossed out, and then add it to each column that is crossed out. Then, go back to Step 4. CostB1B2B3A100.100.5A20.30 0 0A3000.40 CostB1B2B3A10.200.350.40A
22、20.400.100.20A30.150.200.70 CFG Matching as MCSGeneral Maximum Common Subgraph (MCS) Problem: Find the largest subgraph isomorphic to two graphs.Eschweiler et al. discovRE: Efficient Cross-Architecture Identification of Bugs in Binary Code. NDSS. 2016.Weighted Maximum Common Subgraph (MCS) Problem:
23、consider the distance between blocks.McGregor Algorithm for MCS Approximation/incremental search/start with an initial subgraph sWhile(NextPair(s,ai,bj) If(IsFeasible(s,ai,bj) snew=AddPair(s, ai,bj) If (snew is expandable) MCS(snew) BackTrack(snew) A1A2A3A4B1B2B3B5B4A5A2current sB2possible pairsA1B1
24、B5A5feasible pairsA1B1Eschweiler et al. “discovRE: Efficient Cross-Architecture Identification of Bugs in Binary Code.” NDSS. 2016.Wang, et al. A novel efficient algorithm for determining maximum common subgraphs. IV, 2005.Graph EmbeddingAn embedding is a high-dimensional vector for representing the graph.Idea:Create an embedding for each bug.Create an embedding for each function of the target project.Search similar embeddings Xu et al. Neural network-based graph embedding for cross-platform binary code similarity detection. CCS 2017.Generate Attributed Contr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年迁西县招教考试备考题库含答案解析(夺冠)
- 2025年湖北兵器工业职工大学马克思主义基本原理概论期末考试模拟题带答案解析
- 2024年通辽职业学院马克思主义基本原理概论期末考试题附答案解析(夺冠)
- 2025年阳江职业技术学院马克思主义基本原理概论期末考试模拟题带答案解析(必刷)
- 2025年松溪县幼儿园教师招教考试备考题库附答案解析(夺冠)
- 2025年南华大学马克思主义基本原理概论期末考试模拟题带答案解析(夺冠)
- 2025年蒙自县幼儿园教师招教考试备考题库含答案解析(夺冠)
- 2025年四川航天职业技术学院单招职业技能考试题库带答案解析
- 2025年杨凌职业技术学院单招职业适应性考试题库带答案解析
- 2025年山东司法警官职业学院马克思主义基本原理概论期末考试模拟题带答案解析(夺冠)
- 基于区域对比的地理综合思维培养-以澳大利亚和巴西人口分布专题复习课设计(湘教版·八年级)
- 2025年高考(海南卷)历史真题(学生版+解析版)
- 2026河北石家庄技师学院选聘事业单位工作人员36人备考考试试题附答案解析
- NB-SH-T 0945-2017 合成有机酯型电气绝缘液 含2025年第1号修改单
- 企业培训课程需求调查问卷模板
- 2026届福州第三中学数学高二上期末检测模拟试题含解析
- 2026年细胞治疗 免疫性疾病治疗项目商业计划书
- (一模)郑州市2026年高中毕业年级(高三)第一次质量预测数学试卷(含答案及解析)
- NBT 11898-2025《绿色电力消费评价技术规范》
- 2026年总经理工作计划
- 四年级数学(三位数乘两位数)计算题专项练习及答案
评论
0/150
提交评论