WO2017181628A1 - 一种基于符号计算的动态并行程序污点分析方法 - Google Patents

一种基于符号计算的动态并行程序污点分析方法 Download PDF

Info

Publication number
WO2017181628A1
WO2017181628A1 PCT/CN2016/102362 CN2016102362W WO2017181628A1 WO 2017181628 A1 WO2017181628 A1 WO 2017181628A1 CN 2016102362 W CN2016102362 W CN 2016102362W WO 2017181628 A1 WO2017181628 A1 WO 2017181628A1
Authority
WO
WIPO (PCT)
Prior art keywords
pollution
thread
constraint
variable
program
Prior art date
Application number
PCT/CN2016/102362
Other languages
English (en)
French (fr)
Inventor
刘烃
郑庆华
张晓东
郝宇
尹文浩
刘沛
Original Assignee
西安交通大学
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 西安交通大学 filed Critical 西安交通大学
Publication of WO2017181628A1 publication Critical patent/WO2017181628A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics

Definitions

  • the invention belongs to the field of trusted software and software analysis technology, and in particular relates to a dynamic parallel program stain analysis method based on symbol calculation.
  • Dynamic stain analysis records the relationship between pollution sources and pollution sinks, and is widely used in the security field, such as data leakage detection, software attack prevention, malware analysis, and so on. Due to its wide range of applications, there has been a lot of work in the accuracy and efficiency of stain analysis. Unfortunately, existing dynamic stain analysis methods have certain under-taint problems when detecting multi-threaded programs. This is mainly because the input is uncertain compared to the serial program, and the execution timing of the multi-threaded program is also uncertain, which brings great obstacles to the analysis of the stain.
  • the object of the present invention is to provide a dynamic parallel program stain analysis method based on symbol calculation, and construct a constraint table according to the multi-threaded program pollution propagation semantics. Dafa, the pollution verification problem is transformed into a constraint solving problem, the constraint solver is used to detect whether it is polluted, and a counter-example execution path indicating the contamination is generated.
  • a dynamic parallel program stain analysis method based on symbolic calculation comprising the following steps:
  • a further improvement of the present invention is that in the step S1), the program is executed in the symbol execution tool KLEE platform, and the serialized multi-thread program execution path T is collected at the granularity of the bytecode.
  • a further improvement of the present invention is that in the step S2), the input is set as a pollution source. For a statement, if the right variable is contaminated, the variable on the left is contaminated, and the contaminated variable is marked.
  • the pollution flag propagates as the parallel program executes under a particular interlace, collecting the tagged variables and placing them in the pollution set TS.
  • a further improvement of the present invention is that in the step S3), all the threads in the program are The local variable access points are used as pollution sources, and they are marked with pseudo-pollution. During the execution process, these pseudo-contamination marks are propagated inside the respective threads.
  • the constraint model F implies all possible interleaving sequences of the execution path T, including four constraints: program semantic constraints, partial order relationship constraints, read-write relationship constraints, and pollution propagation constraints.
  • the definitions are as follows:
  • Interleave matching constraint define the definition between threads - use the chain, specify the value read by the shared variable, must come from the initial value and the most recent written value; meanwhile, when there is read and write between threads, there must be corresponding pollution propagation.
  • Pollution propagation constraints Specify the pollution status of the internal variables of the thread to determine whether the data is from the contaminated variable or the uncontaminated variable;
  • the definition-use chain is: convert each thread sequence into SSA format. For each execution sequence of SSA format, removing the shared access point is a complete definition-use chain.
  • step S4), the construction method of the constraint model F includes the following operations:
  • T i ⁇ e 1 , e 2 ,..., e n ⁇ as the execution sequence of thread i
  • e n represents the nth event of T i
  • O(e n ) represents event e n
  • the partial order relationship is constrained to Includes the following four memory model constraints Lock synchronization constraint Conditional variable constraint Thread creation end constraint Their respective calculation methods are:
  • Lock synchronization constraint The purpose of the lock/unlock operation is to construct a lock synchronization semantic constraint, requiring lock/unlock set L in the same mutex, for any two lock/unlock event pairs: l i /u i and l k / u k , must satisfy the formula:
  • the lock pair l i /u i occurs either before the lock pair l k /u k or after it;
  • Conditional variable constraints The purpose of the wait/signal operation is to construct a conditional variable synchronous semantic constraint. To satisfy the condition: each wait operation must correspond to a signal operation, and a signal operation wakes up at most one wait operation.
  • WT As a collection of all wait operations on the cond, let SG be the set of all signal operations on the cond. To satisfy the above conditions, the following formula must be used:
  • SG wt represents a set of signal operations that e wt can match, and e sg is any signal operation event in SG wt , using variables Whether it is equal to 1 to indicate whether e sg matches e wt .
  • Sub formula Indicates that for each wait operation e wt must have a signal operation to match it;
  • Thread creation end constraint First, if the event creates a thread, all events of the created thread must be executed after this event; if the event execution thread terminates the operation, all events of the terminated thread must be before this event; Let C be the set of events for the create/fork operation, let J be the collection of events for the join operation; given constraints:
  • first(e c ) is the order of the first event of the thread created by e c
  • e j is the thread termination event
  • last(e j ) is the order of the end event of the thread terminated by e j ;
  • e r is a read event
  • e w and e x are write events
  • v r and v w are variables operated by events e r and e w
  • the expression of the formula means that if v r in the event e r is taken The value comes from the v w in the event e w , first of all to satisfy e r after e w , ie O(e w ) ⁇ O(e r ); then all the writes are satisfied either before e w or at e r after; if the e r v r v w values derived from the event e w, the contamination will spread labeled v w to v r.
  • a further improvement of the present invention is that the existing constraint model is used in the step S6) to find out whether there is an irreversible branch, because in the execution of the multi-threaded program, some branches are affected by the statement timing relationship.
  • the expression corresponding to all branches C is removed from F to obtain F'.
  • c i in C solve If it is solvable, it means it can be negated.
  • o i represents the timing of c i . among them, Indicates that the current branch is negated.
  • step S7) determines whether there is still a new path, and if so, returns to S2) to continue the verification; otherwise, the algorithm ends.
  • a multi-threaded program pollution propagation constraint model is proposed to transform the variable pollution verification problem of multi-threaded program into a constraint solving problem.
  • This model is constructed constrained by program semantics.
  • the constructed expression contains all possible interleaving sequences, and the constraint solver is used to check whether the variable is contaminated under some kind of interlacing.
  • Figure 1 is a general flow chart of the method of the present invention.
  • FIG. 2 is a flow chart of a method for constructing a multi-threaded program pollution propagation model.
  • the sample program to be tested is as follows, x and z are shared variables, thread 0 creates thread 1 and thread 2 on lines 3 and 4, and sets argv[1] as the source of pollution, and the initial value of argv[1] Is 1.
  • a dynamic parallel program stain analysis method based on symbol calculation includes the following steps:
  • Step S2): According to the path T, collect the collected variable set TS ⁇ a@L1, y@L2, m@L3, x@L6, z@L7, n@L4, x@L10 ⁇ , where a@ L1 represents the variable a in line 1.
  • the entire constraint model F implies all possible contamination propagation sequences of the execution path. Specifically, as shown in Figure 2 As shown, generate the corresponding logical expression as follows:
  • the upper corners of the global variables x and y indicate read (r) or write (w), and the lower corners distinguish between different read or write operations.
  • Step S5) It can be known from S3) that z@L11 is a variable to be verified, and the condition of being contaminated is expressed as an expression for removing the branch statement from F. Solving expression The result is solvable, and the sequence ⁇ 1, 2, 3, 6, 7, 8F, 4, 10, 11, 5 ⁇ is obtained from its solution. This sequence causes z@L11 to be contaminated.
  • Step S6) removing the expression of the branch statement from F, that is, The expression F' is obtained.
  • Step S7) Since both sides of the branch of Line 8 have been traversed, a new path no longer exists. Then the algorithm ends.
  • the method of the present invention can detect the pollution variables under other interlaces under a given input, and can also detect the pollution variables under other branches, and the accuracy is obviously improved.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Debugging And Monitoring (AREA)

Abstract

一种基于符号计算的动态并行程序污点分析方法,根据并行程序的污染传播语义构建约束表达式,采用约束求解器验证该变量是否会在某种交织下被污染,并且生成被污染时的证据序列;首先,在给定的污染输入下执行程序,收集特定交织下的污染变量实例集合;其次,符号分析:根据并行程序污染传播语义,将执行路径转化为约束表达式以验证此路径是否新的被污染变量;然后,路径探索:利用此约束模型来验证是否存在分支可被取反,以寻找新路径;最后,继续验证新路径,符号分析与路径探索迭代进行,直至不再产生新路径;此方法的目标是给定输入下,验证特定调度下是否存在一些变量会在其他交织中被污染;且寻找新语句,以发现新的污染变量。

Description

一种基于符号计算的动态并行程序污点分析方法 技术领域
本发明属于可信软件及软件分析技术领域,特别涉及一种基于符号计算的动态并行程序污点分析方法。
背景技术
动态污点分析记录污染源与污染沉渍之间的关系,安全领域内被广泛应用,譬如数据泄露检测,软件攻击防范,恶意软件分析等等。正是由于其广泛的应用,在污点分析的精度与效率防范已有大量的工作。不幸的是,现有的动态污点分析方法在检测多线程程序时,都存在一定的under-taint问题。这主要是因为相比之于串行程序仅有输入不确定,多线程程序还有执行时序也不确定,给污点分析带来了巨大障碍。
然而,分析多线程程序存在一定的难度,难以重现并行错误。多线程程序具有以下几个特征:1)用户难以控制所有线程之间的执行顺序;2)在调试器中使用插装技术或者断点调试方法会产生副作用,导致某些错误消失;3)由于操作系统与运行时环境的原因,导致错误发生的序列很少再次发生;4)线程交织导致的空间状态爆炸,例如,对于有n个线程,每个线程执行k指令的程序,其交织序列数量可达(nk)!/(k!)n>=(n!)k。即使在可控制线程调度的假设下,程序员也无法人工穷举所有线程交织。
目前,已有大量动态污点分析方面的工作,但针对多线程程序的方法很少且存在很大的精度问题,因为其仅能对单一交织路径下的污点进行分析,无法其他交织下的污点,更不用谈同一输入下不同分支的污点。
发明内容
为了克服上述现有技术的缺点,本发明的目的在于提供一种基于符号计算的动态并行程序污点分析方法,根据多线程程序污染传播语义构建约束表 达式,将污染验证问题转化为约束求解问题,采用约束求解器检测是否被污染,并生成说明被污染的反例执行路径。
为了实现上述目的,本发明采用的技术方案是:
一种基于符号计算的动态并行程序污点分析方法,包括如下步骤:
S1)执行待测程序,以记录程序的执行路径T;
S2)收集执行路径T上的污染变量,放入污染集合TS;
S3)计算执行路径T上的潜在污染变量,放入潜在污染集合PTS,所谓的潜在污染变量,即与被污染变量有数值依赖关系,但是又没有在执行路径T上被污染;
S4)根据多线程程序污染传播语义,将执行路径T构建为约束模型F,此模型为一阶逻辑表达式,且包括执行路径T上所有可能污染传播路径;
S5)构建潜在污染集合PTS内每一个变量pts的污染发生条件ρpts,在约束模型F上验证是否会被污染,利用约束求解器验证F∧ρpts,如果可解表示存在某种交织使得pts被污染,且将其放入集合TS;如果不可解,表示该变量在T的所有交织下都不会被污染;
S6)针对执行路径T上的任一分支b,构建其取反的条件Negate(b),利用约束求解器验证F∧Negate(b)是否有解。如果有解,根据求解结果指导程序执行出新路径Tnew;如果不可解,则验证下一分支。
S7)如果在给定输入下,取反分支之后已不再形成新路径,则停止算法。如果尚存在新路径,则继续迭代。
本发明进一步的改进在于:所述步骤S1)中,在符号执行工具KLEE平台内执行程序,以字节码的粒度收集序列化的多线程程序执行路径T。
本发明进一步的改进在于:所述步骤S2)中,将输入设定为污染源,对于一个语句,右边变量如果被污染,那么左边的变量就会被污染,被污染的变量则做上标记,此污染标记会随着并行程序在特定交织下执行而传播,收集被标记的变量,放入污染集合TS。
本发明进一步的改进在于:所述步骤S3)中,将程序中每一个线程中的全 局变量访问点都作为污染源,并且做上伪污染标记,执行过程中,在各自线程内部传播这些伪污染标记。用S2)中得到的真实污染标记结果,替换伪污染标记,得到的集合为S,则潜在污染变量为在S中却不在TS中的变量,表示为PTS=S-TS。
本发明进一步的改进在于:所述步骤S4)中,约束模型F蕴含了执行路径T所有可能的交织序列,包括四种约束:程序语义约束、偏序关系约束、读写关系约束以及污染传播约束,定义分别如下:
1)程序语义约束:描述线程内部的定义-使用链,以及控制线程内部状态转换;
2)偏序关系约束:线程内部语句之间的关系,采用顺序一致性的语义;线程间语句的关系,按照create/join、wait/signal、lock/unlock的语义规定来构建;
3)交织匹配约束:定义线程间的定义-使用链,规定共享变量所读取到的值,必须来自初始值以及最近的写值;同时,当线程间有读写时,也要有对应污染传播。
4)污染传播约束:规定线程内部变量的污染状态,确定其数据是来自被污染变量还是未被污染变量;
其中,定义-使用链为:将每一个线程序列转化为SSA格式,对于每一个SSA格式的执行序列,除去共享访问点都是一个完整的定义-使用链。
本发明进一步的改进在于:所述步骤S4),约束模型F的构建方法包括以下操作:
1)计算程序语义约束Φps,以控制线程内部状态转移;
2)计算偏序关系约束Φpo,以构建线程间或线程内语句之间可能的时序关系;
3)计算交织匹配约束Φim,以建立线程间的定义-使用链以及污染传播的关系;
4)计算污染传播约束Φtp,以线程内部污染传播的流程;
最后,结合以上四种约束,构成约束模型F=Φps∧Φpo∧Φim∧Φtp
本发明进一步的改进在于:定义执行路径事件集合
Figure PCTCN2016102362-appb-000001
其中k为线程数量,Ti={e1,e2,...,en}作为线程i的执行序列,en表示Ti的第n个事件,O(en)表示事件en的顺序,n表示Ti的事件数量,则:
所述程序语义约束的计算方法:
将每一个线程序列转化为SSA格式,直接将SSA格式序列转化为路径表达式;
所述偏序关系约束为
Figure PCTCN2016102362-appb-000002
包括以下四种内存模型约束
Figure PCTCN2016102362-appb-000003
锁同步约束
Figure PCTCN2016102362-appb-000004
条件变量约束
Figure PCTCN2016102362-appb-000005
线程创建结束约束
Figure PCTCN2016102362-appb-000006
其各自计算方法为:
内存模型约束:采用顺序一致性模型,所有操作完全按程序的顺序执行,线程内的事件顺序符合约束:
Figure PCTCN2016102362-appb-000007
其中ei与ei+1表示同一线程内连续的两个事件,τ表示所有线程序列;
锁同步约束:lock/unlock操作的目的为构建锁同步语义约束,要求在同一互斥锁的lock/unlock集合L中,对于任意两个lock/unlock事件对:li/ui与lk/uk,须满足公式:
Figure PCTCN2016102362-appb-000008
其中,锁对li/ui要么发生在锁对lk/uk之前,要么发生在其后;
条件变量约束:wait/signal操作的目的是构建条件变量同步语义约束,要满足条件:每一个wait操作必须对应一个signal操作,而一个signal操作至多唤醒一个wait操作,对于同一条件变量cond,令WT作为在cond上所有wait操作的集合,令SG作为在cond上所有signal操作的集合,如要满足之上的条件,须有以下公式:
Figure PCTCN2016102362-appb-000009
其中,ewt为WT中的任一元素,SGwt表示ewt可以匹配的signal操作的集合,esg为SGwt中任一signal操作事件,利用变量
Figure PCTCN2016102362-appb-000010
是否等于1来表示esg是否与ewt相匹配。子公式
Figure PCTCN2016102362-appb-000011
表示,对于每一个wait操作ewt必须有一个signal操作与之匹配;
线程创建结束约束:首先规定,如果事件创建一个线程,那么被创建线程的所有事件都要在此事件之后执行;如果事件执行线程终止操作,那么被终止线程的所有事件都要在此事件之前;令C为create/fork操作的事件集合,令J作为join操作的事件集合;给定约束:
Figure PCTCN2016102362-appb-000012
其中,ec为线程创建事件,first(ec)为ec所创建的线程首个事件的顺序;ej为线程终止事件;last(ej)为ej所终止的线程末尾事件的顺序;
所述交织匹配约束的计算方法:
使共享变量的读来自于最近的写,对于同一共享变量v,令R作为所有对其进行读操作的事件集合,令W作为所有对其进行写操作的事件集合,给出以下公式:
Figure PCTCN2016102362-appb-000013
其中,er为读事件,ew与ex为写事件,vr和vw为事件er与ew所操作的变量,公式所表达的意思是,如果事件er中的vr取值来自于事件ew中的vw,首先要满足er在ew之后,即O(ew)<O(er);然后要满足所有的写要么在ew之前,要么在er之后;如果er中的vr取值来自于事件ew中的vw,那么vw的污染标记也会传播给vr
所述污染传播约束的计算方法:
将每一个线程序列内每一个变量v的污染标记为v.tag,按照执行语句的 句型直接转换为表达,譬如,v=a OP b;那么对应的污染传播表达式为v.tag=a.tag or b.tag;
最终将以上四种约束相与构成约束模型F。
本发明进一步的改进在于:所述步骤S5)中,对于PTS中任一变量pts,其污染标记为pts.tag,用pts.tag=1来表示pts被污染的情况,求解F∧pts.tag=1。;如果可解,表示pts可被污染;如果不可解,表示pts不可以被污染。
本发明进一步的改进在于:所述步骤S6)中利用现有约束模型寻找是否存在可取反的分支,因为在多线程程序执行过程中,有些分支会受到语句时序关系的影响。首先,从F中去除所有分支C对应的表达式,得到F′。然后,对于C中的每一个分支ci,求解
Figure PCTCN2016102362-appb-000014
如果可解,表示其可被取反。其中oi表示ci的时序。其中,
Figure PCTCN2016102362-appb-000015
表示取反当前的分支,
Figure PCTCN2016102362-appb-000016
表示对于其他分支,如果发生在被取反分支之前,则必须保持不变。
本发明进一步的改进在于:所述步骤S7)中判断是否尚有新路径,如果存在,则回到S2)继续验证;否则,结束算法。
与现有技术相比,本发明的有益效果是:
(1)提出一种多线程程序污染传播约束模型,将多线程程序的变量污染验证问题转化为约束求解问题。此模型按照程序语义进行约束构建,所构建的表达式包含了所有可能的交织序列,利用约束求解器检查该变量是否会在某种交织下被污染。
(2)验证单条路径所有的交织情况下的污染变量。
(3)验证给定输入下所有路径的污染变量。
(4)给出每一个变量被污染的污染传播交织路径。
附图说明
图1为本发明方法整体流程图。
图2为多线程程序污染传播模型构建方法流程图。
具体实施方式
下面结合附图和实施例详细说明本发明的实施方式。
待测示例程序如下所示,x与z为共享变量,线程0在第3行与第4行创建了线程1与线程2,且设定argv[1]为污染源,且argv[1]初值为1。
Figure PCTCN2016102362-appb-000017
如图1所示,一种基于符号计算的动态并行程序污点分析方法,包括如下步骤:
步骤S1):在输入argv[1]=1情况下随机执行示例程序,得到初始路径T={1,2,3,6,7,8F,4,10,5,11}.
步骤S2):根据路径T,收集其被污染的变量集合TS={a@L1,y@L2,m@L3,x@L6,z@L7,n@L4,x@L10},其中a@L1表示在line 1的变量a。
步骤S3):再分析路径T,如下所示,给每一个线程做一个伪标记,最后利用TS中的变量污染标记替换这些伪标记,即得到集合S={a@L1,y@L2,m@L3,x@L6,z@L7,n@L4,x@L10,z@L11},其潜在污染集合为PTS=S-TS={z@L11}。
Figure PCTCN2016102362-appb-000018
步骤S4):根据多线程程序污点传播语义将执行路径中状态转移、污染传播、线程交织关系转化为无量词一阶逻辑表达式,构建执行路径T的约束模型F,包括程序语义约束、偏序关系约束、线程交织约束、污染传播约束。整个约束模型F蕴含了执行路径所有可能的污染传播序列。具体地,如图2 所示,按照以下步骤生成对应的逻辑表达式:
S401):根据以下程序路径T的SSA格式,将每一句表达式相与,则得到程序语义约束。
Figure PCTCN2016102362-appb-000019
其中,对于全局变量x与y的上角标表示读(r)或写(w),下角标区分不同的读或写操作。
S402):构建偏序关系约束:线程内部时序关系,遵守顺序一致性,如o1<o2表示line 1在line 2之前发生。线程间的关系,本示例中仅有线程创建关系,例如o3<op2表示line 3发生被其创建线程的第一条语句。
(o1<o2<o3<o4<o5)∧(op2<o6<o7<o8)∧
(op3<o10<o11)∧o3<op2∧o4<op3
S403):构建交织匹配约束,其如下所示:
Figure PCTCN2016102362-appb-000020
S404):构建污染传播约束,按照左侧路径T的SSA格式,转换为右侧的污染传播表达式,将其相与,即得到污染传播约束。如下所示:
Figure PCTCN2016102362-appb-000021
步骤S5):由S3)可知,z@L11为待验证变量,其被污染的条件表示为从F中去除分支语句的表达式
Figure PCTCN2016102362-appb-000022
求解表达式
Figure PCTCN2016102362-appb-000023
结果可解,从其解中得到序列{1,2,3,6,7,8F,4,10,11,5}。此序列即使得z@L11被污 染。
步骤S6):从F中去除分支语句的表达式,即
Figure PCTCN2016102362-appb-000024
得到表达式F′。根据取反规定,求解
Figure PCTCN2016102362-appb-000025
结果可解,,从其解中得出一个部分路径调度序列S={1,2,3,6,7,4,5,8T}。按照此序列知道执行,得到新路径T′={1,2,3,6,7,4,5,8T,9,10,11}。对此路径从新验证,发现w@L9也会被污染。
步骤S7):由于Line 8的分支两侧都被遍历过,已不再存在新路径。则算法结束。
总结:本发明的方法,相比现有方法,在给定输入下,可以检测到其他交织下的污染变量,也可以检测到其他分支下的污染变量,在精度上有很明显的提高。

Claims (10)

  1. 一种基于符号计算的动态并行程序污点分析方法,其特征在于,包括如下步骤:
    S1)执行待测程序,以记录程序的执行路径T;
    S2)收集执行路径T上的污染变量,放入污染集合TS;
    S3)计算执行路径T上的潜在污染变量,放入潜在污染集合PTS,所述潜在污染变量,即与被污染变量有数值依赖关系,但是又没有在执行路径T上被污染;
    S4)根据多线程程序污染传播语义,将执行路径T构建为约束模型F,此模型为一阶逻辑表达式,且包括执行路径T上所有可能污染传播路径;
    S5)构建潜在污染集合PTS内每一个变量pts的污染发生条件ρpts,在约束模型F上验证是否会被污染,利用约束求解器验证F∧ρpts,如果可解表示存在某种交织使得pts被污染,且将其放入污染集合TS;如果不可解,表示该变量在执行路径T的所有交织下都不会被污染;
    S6)针对执行路径T上的任一分支b,构建其取反的条件Negate(b),利用约束求解器验证F∧Negate(b)是否有解,如果有解,根据求解结果指导程序执行出新路径Tnew;如果不可解,则验证下一分支;
    S7)如果在给定输入下,取反分支之后已不再形成新路径,则停止算法,如果尚存在新路径,则继续迭代。
  2. 根据权利要求1所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S1)中,在符号执行工具KLEE平台内执行待测程序,以字节码的粒度收集序列化的多线程程序执行路径T。
  3. 根据权利要求1所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S2)中,将输入设定为污染源,对于一个语句,右边变量如果被污染,那么左边的变量就会被污染,被污染的变量做上标记,此污染 标记会随着并行程序在特定交织下执行而传播,收集被标记的变量,放入污染集合TS。
  4. 根据权利要求3所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S3)中,将程序中每一个线程中的全局变量访问点都作为污染源,并且做上伪污染标记,执行过程中,在各自线程内部传播这些伪污染标记,用步骤S2)中得到的真实污染标记结果,替换伪污染标记,得到的集合为S,则潜在污染变量为在S中却不在TS中的变量,表示为PTS=S-TS。
  5. 根据权利要求1所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S4)中,约束模型F蕴含了执行路径T所有可能的交织序列,包括四种约束:程序语义约束、偏序关系约束、读写关系约束以及污染传播约束,定义分别如下:
    1)程序语义约束:描述线程内部的定义-使用链,以及控制线程内部状态转换;
    2)偏序关系约束:线程内部语句之间的关系,采用顺序一致性的语义;线程间语句的关系,按照create/join、wait/signal、lock/unlock的语义规定来构建;
    3)交织匹配约束:定义线程间的定义-使用链,规定共享变量所读取到的值,必须来自初始值以及最近的写值;同时,当线程间有读写时,也要有对应污染传播。
    4)污染传播约束:规定线程内部变量的污染状态,确定其数据是来自被污染变量还是未被污染变量;
    其中,定义-使用链为:将每一个线程序列转化为SSA格式,对于每一个SSA格式的执行序列,除去共享访问点都是一个完整的定义-使用链。
  6. 根据权利要求5所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S4)中,约束模型F的构建方法包括以下操作:
    1)计算程序语义约束Φps,以控制线程内部状态转移;
    2)计算偏序关系约束Φpo,以构建线程间或线程内语句之间可能的时序 关系;
    3)计算交织匹配约束Φim,以建立线程间的定义-使用链以及污染传播的关系;
    4)计算污染传播约束Φtp,以线程内部污染传播的流程;
    最后,结合以上四种约束,构成约束模型F=Φps∧Φpo∧Φim∧Φtp
  7. 根据权利要求6所述基于符号计算的动态并行程序污点分析方法,其特征在于,定义执行路径事件集合
    Figure PCTCN2016102362-appb-100001
    其中k为线程数量,Ti={e1,e2,…,en}作为线程i的执行序列,en表示Ti的第n个事件,O(en)表示事件en的顺序,n表示Ti的事件数量,则:
    所述程序语义约束的计算方法:
    将每一个线程序列转化为SSA格式,直接将SSA格式序列转化为路径表达式;
    所述偏序关系约束为
    Figure PCTCN2016102362-appb-100002
    包括四种内存模型约束
    Figure PCTCN2016102362-appb-100003
    锁同步约束
    Figure PCTCN2016102362-appb-100004
    条件变量约束
    Figure PCTCN2016102362-appb-100005
    和线程创建结束约束
    Figure PCTCN2016102362-appb-100006
    其各自计算方法为:
    内存模型约束:采用顺序一致性模型,所有操作完全按程序的顺序执行,线程内的事件顺序符合约束:
    Figure PCTCN2016102362-appb-100007
    其中ei与ei+1表示同一线程内连续的两个事件,τ表示所有线程序列;
    锁同步约束:lock/unlock操作的目的为构建锁同步语义约束,要求在同一互斥锁的lock/unlock集合L中,对于任意两个lock/unlock事件对:li/ui与lk/uk,须满足公式:
    Figure PCTCN2016102362-appb-100008
    其中,锁对li/ui要么发生在锁对lk/uk之前,要么发生在其后;
    条件变量约束:wait/signal操作的目的是构建条件变量同步语义约束, 要满足条件:每一个wait操作必须对应一个signal操作,而一个signal操作至多唤醒一个wait操作,对于同一条件变量cond,令WT作为在cond上所有wait操作的集合,令SG作为在cond上所有signal操作的集合,如要满足之上的条件,须有以下公式:
    Figure PCTCN2016102362-appb-100009
    其中,ewt为WT中的任一元素,SGwt表示ewt可以匹配的signal操作的集合,esg为SGwt中任一signal操作事件,利用变量
    Figure PCTCN2016102362-appb-100010
    是否等于1来表示esg是否与ewt相匹配,子公式
    Figure PCTCN2016102362-appb-100011
    表示,对于每一个wait操作ewt必须有一个signal操作与之匹配;
    线程创建结束约束:首先规定,如果事件创建一个线程,那么被创建线程的所有事件都要在此事件之后执行;如果事件执行线程终止操作,那么被终止线程的所有事件都要在此事件之前;令C为create/fork操作的事件集合,令J作为join操作的事件集合;给定约束:
    Figure PCTCN2016102362-appb-100012
    其中,ec为线程创建事件,first(ec)为ec所创建的线程首个事件的顺序;ej为线程终止事件;last(ej)为ej所终止的线程末尾事件的顺序;
    所述交织匹配约束的计算方法:
    使共享变量的读来自于最近的写,对于同一共享变量v,令R作为所有对其进行读操作的事件集合,令W作为所有对其进行写操作的事件集合,给出以下公式:
    Figure PCTCN2016102362-appb-100013
    其中,er为读事件,ew与ex为写事件,vr和vw为事件er与ew所操作的变量,公式所表达的意思是,如果事件er中的vr取值来自于事件ew中的vw,首先要满足er在ew之后,即O(ew)<O(er);然后要满足所有的写要么在ew之前, 要么在er之后;如果er中的vr取值来自于事件ew中的vw,那么vw的污染标记也会传播给vr
    所述污染传播约束的计算方法:
    将每一个线程序列内每一个变量v的污染标记为v.tag,按照执行语句的句型直接转换为表达,譬如,v=a OP b;那么对应的污染传播表达式为v.tag=a.tag or b.tag;
    最终将以上四种约束相与构成约束模型F。
  8. 根据权利要求7所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S5)中,对于潜在污染集合PTS中任一变量pts,其污染标记为pts.tag,则用pts.tag=1来表示pts被污染的情况,求解F∧pts.tag=1;如果可解,表示pts可被污染;如果不可解,表示pts不可以被污染。
  9. 根据权利要求1所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S6)中利用现有约束模型寻找是否存在可取反的分支,首先,从约束模型F中去除所有分支C对应的表达式,得到F′,然后,对于C中的每一个分支ci,求解
    Figure PCTCN2016102362-appb-100014
    如果可解,表示其可被取反,其中oi表示ci的时序。
  10. 根据权利要求1所述基于符号计算的动态并行程序污点分析方法,其特征在于,所述步骤S7)中判断是否尚有新路径,如果存在,则回到S2)继续验证;否则,结束算法。
PCT/CN2016/102362 2016-04-19 2016-10-18 一种基于符号计算的动态并行程序污点分析方法 WO2017181628A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610243975.6 2016-04-19
CN201610243975.6A CN105955877B (zh) 2016-04-19 2016-04-19 一种基于符号计算的动态并行程序污点分析方法

Publications (1)

Publication Number Publication Date
WO2017181628A1 true WO2017181628A1 (zh) 2017-10-26

Family

ID=56917681

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/102362 WO2017181628A1 (zh) 2016-04-19 2016-10-18 一种基于符号计算的动态并行程序污点分析方法

Country Status (2)

Country Link
CN (1) CN105955877B (zh)
WO (1) WO2017181628A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113176990A (zh) * 2021-03-25 2021-07-27 中国人民解放军战略支援部队信息工程大学 一种支持数据间关联分析的污点分析框架及方法
CN113918948A (zh) * 2021-12-13 2022-01-11 北京雁翎网卫智能科技有限公司 一种基于语义分析的无害化处理识别方法
US20220027861A1 (en) * 2020-07-24 2022-01-27 Oracle International Corporation Using constraint programming to obtain a machine maintenance schedule for maintenance tasks
CN115329346A (zh) * 2022-10-09 2022-11-11 支付宝(杭州)信息技术有限公司 一种检测侧信道漏洞的方法和装置
CN116303042A (zh) * 2023-03-22 2023-06-23 中国人民解放军国防科技大学 一种基于污点分析的软件配置故障检测方法
CN116383070A (zh) * 2023-04-07 2023-07-04 南京航空航天大学 一种面向高mc/dc的符号执行方法

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105955877B (zh) * 2016-04-19 2017-03-29 西安交通大学 一种基于符号计算的动态并行程序污点分析方法
CN106649124B (zh) * 2016-12-28 2019-04-02 桂林电子科技大学 一种基于Actor模型的并行动态符号执行方法和系统
CN111291373B (zh) * 2020-02-03 2022-06-14 思客云(北京)软件技术有限公司 用于分析数据污染传播的方法、设备和计算机可读存储介质
CN114036072B (zh) * 2022-01-06 2022-04-08 湖南泛联新安信息科技有限公司 一种支持自动化检测程序缺陷的方法和系统
CN116560998B (zh) * 2023-05-16 2023-12-01 中国人民解放军国防科技大学 一种面向i/o顺序性的数据库性能问题检测方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120304010A1 (en) * 2011-05-25 2012-11-29 Microsoft Corporation Code coverage-based taint perimeter detection
CN104077144A (zh) * 2014-07-07 2014-10-01 西安交通大学 基于多线程程序约束构建的数据竞争检测与证据生成方法
CN104077226A (zh) * 2014-07-07 2014-10-01 西安交通大学 基于程序约束构建的多线程程序输出唯一性检测与证据生成方法
CN104598383A (zh) * 2015-02-06 2015-05-06 中国科学院软件研究所 一种基于模式的动态漏洞挖掘集成系统和方法
CN105117336A (zh) * 2015-08-26 2015-12-02 中国科学院软件研究所 一种动态标记处理控制依赖的方法
CN105955877A (zh) * 2016-04-19 2016-09-21 西安交通大学 一种基于符号计算的动态并行程序污点分析方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120304010A1 (en) * 2011-05-25 2012-11-29 Microsoft Corporation Code coverage-based taint perimeter detection
CN104077144A (zh) * 2014-07-07 2014-10-01 西安交通大学 基于多线程程序约束构建的数据竞争检测与证据生成方法
CN104077226A (zh) * 2014-07-07 2014-10-01 西安交通大学 基于程序约束构建的多线程程序输出唯一性检测与证据生成方法
CN104598383A (zh) * 2015-02-06 2015-05-06 中国科学院软件研究所 一种基于模式的动态漏洞挖掘集成系统和方法
CN105117336A (zh) * 2015-08-26 2015-12-02 中国科学院软件研究所 一种动态标记处理控制依赖的方法
CN105955877A (zh) * 2016-04-19 2016-09-21 西安交通大学 一种基于符号计算的动态并行程序污点分析方法

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220027861A1 (en) * 2020-07-24 2022-01-27 Oracle International Corporation Using constraint programming to obtain a machine maintenance schedule for maintenance tasks
US11797951B2 (en) * 2020-07-24 2023-10-24 Oracle International Corporation Using constraint programming to obtain a machine maintenance schedule for maintenance tasks
CN113176990A (zh) * 2021-03-25 2021-07-27 中国人民解放军战略支援部队信息工程大学 一种支持数据间关联分析的污点分析框架及方法
CN113918948A (zh) * 2021-12-13 2022-01-11 北京雁翎网卫智能科技有限公司 一种基于语义分析的无害化处理识别方法
CN113918948B (zh) * 2021-12-13 2022-03-22 北京雁翎网卫智能科技有限公司 一种基于语义分析的无害化处理识别方法
CN115329346A (zh) * 2022-10-09 2022-11-11 支付宝(杭州)信息技术有限公司 一种检测侧信道漏洞的方法和装置
CN116303042A (zh) * 2023-03-22 2023-06-23 中国人民解放军国防科技大学 一种基于污点分析的软件配置故障检测方法
CN116303042B (zh) * 2023-03-22 2023-09-12 中国人民解放军国防科技大学 一种基于污点分析的软件配置故障检测方法
CN116383070A (zh) * 2023-04-07 2023-07-04 南京航空航天大学 一种面向高mc/dc的符号执行方法
CN116383070B (zh) * 2023-04-07 2023-12-05 南京航空航天大学 一种面向高mc/dc的符号执行方法

Also Published As

Publication number Publication date
CN105955877A (zh) 2016-09-21
CN105955877B (zh) 2017-03-29

Similar Documents

Publication Publication Date Title
WO2017181628A1 (zh) 一种基于符号计算的动态并行程序污点分析方法
WO2016004808A1 (zh) 基于多线程程序约束构建的数据竞争检测与证据生成方法
Wallace Modular architectural representation and analysis of fault propagation and transformation
Bi et al. Applying propositional logic to workflow verification
US8527976B2 (en) System and method for generating error traces for concurrency bugs
WO2016004806A1 (zh) 基于程序约束构建的多线程程序输出唯一性检测与证据生成方法
US10409706B2 (en) Automated test generation for structural coverage for temporal logic falsification of cyber-physical systems
CN105868116A (zh) 基于语义变异算子的测试用例生成和优化方法
Xu et al. Experience mining Google's production console logs
Liu et al. Word level feature discovery to enhance quality of assertion mining
Keng et al. Automated debugging of SystemVerilog assertions
Meyer et al. Embedding hindsight reasoning in separation logic
Höfig Failure-dependent timing analysis-a new methodology for probabilistic worst-case execution time analysis
Zhang et al. GoDetector: Detecting concurrent bug in go
Codish et al. Solving partial order constraints for LPO termination
Charvát et al. Using formal verification of parameterized systems in RAW hazard analysis in microprocessors
CN117520199B (zh) 基于静态符号执行的数值软件缺陷检测方法及装置
Han et al. Type redefinition plagiarism detection of token-based comparison
Tang et al. TaintSE: Dynamic Taint Analysis Combined with Symbolic Execution and Constraint Association
Helmy A survey on kernel specification and verification
Ritter Sequential equivalence checking by symbolic simulation
Xu et al. Analysis of Concurrent Systems Based on Interval Order
Wang et al. An efficient complex event detection model for high proportion disordered RFID event stream
Jiang et al. A Thread Modularity Approach for Verification Concurrent Software Based on Abstract Interpretation
Chu Blockchain Smart Contract Threat Detection Technology Based on Symbolic Execution

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16899212

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16899212

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 24/05/2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16899212

Country of ref document: EP

Kind code of ref document: A1