Sparse Representa+on of Implicit Flows with Applica+ons to Side-Channel Detec+on. Bruno Rodrigues Diego Aranha Fernando Pereira

Size: px
Start display at page:

Download "Sparse Representa+on of Implicit Flows with Applica+ons to Side-Channel Detec+on. Bruno Rodrigues Diego Aranha Fernando Pereira"

Transcription

1 Sparse Representa+on of Implicit Flows with Applica+ons to Side-Channel Detec+on Bruno Rodrigues Diego Aranha Fernando Pereira

2 Goal The goal of this work is to implement informa+on flow analysis precisely and efficiently in low level languages

3 Goal The goal of this work is to implement informa+on flow analysis precisely and efficiently in low level languages Informa+on flows from variable s to variable d if the value of s determines the value of d. Explicit flows: d = f(..., s,...) Implicit flows: d = s? 0 : 1

4 Contribu+ons The goal of this work is to implement informa+on flow analysis precisely and efficiently in low level languages We avoid worst cases in the technique used by Ferrante et al to build Dependence Graphs. : The program dependence graph and its use in op+miza+on TOPLAS 1987

5 Contribu+ons The goal of this work is to implement informa+on flow analysis precisely and efficiently in low level languages We avoid worst cases in the technique used by Ferrante et al to build Dependence Graphs. We reduce the complexity of implemen+ng Hunt and Sands' System of Security Types. : On flow-sensi+ve security types POPL 2006

6 Contribu+ons The goal of this work is to implement informa+on flow analysis precisely and efficiently in low level languages We avoid worst cases in the technique used by Ferrante et al to build Dependence Graphs. We reduce the complexity of implemen+ng Hunt and Sands' System of Security Types. We have detected security issues in real-world crypto libraries, such as TrueCrypt and OpenSSL.

7 The Challenge Find an efficient way to track implicit flows. int b; if (p) { b = 0; } else { b = 1; } This code contains an implicit flow of informa+on from predicate p to variable b.

8 The Key Idea "The paper proposes an analysis to efficiently discover and represent implicit informa9on flows in programs in sta9c single assignment (SSA) form. It achieves this by focusing on control dependencies from values to values instead of from values to instruc9ons". Sta+c Single Assignment sparse analysis Control dependences from values to values : quo+ng comment from anonymous referee (CC'16)

9 Dependence Graphs Original View Ver+ces are instruc+ons Edge from i 0 to i 1 if i 0 may determine the behavior of i 1 Dependence Graphs Our View Ver+ces are variables in the SSA-form program Edge from v 0 to v 1 if the value of v 0 determines the value of v 1 : The program dependence graph and its use in op+miza+on TOPLAS 1987

10 Example int genkeymask( int seed, l a int* t1, int* t2 ) { uint_64 r; int i = 0; r = random(seed); while (i < 64) { if (r & 1) { t1[i] = 1; } else { t2[i] = 1; } r >>= 1; i++; } } r 0 = random(seed) i 0 = 0 l d l c a 0 = t 1 + i 1 *a 0 = 1 l f p 1 = r 1 & 1 branch p 1 l e l e l b r 2 = r 1 >> 1 i 1 = ϕ(i 0, i 2 ) r 1 = ϕ(r 0, r 2 ) p 0 = (i 1 < 64)? branch p 0 l c a 1 = t 2 + i 1 *a 1 = 1 i 0 i 1 p 0 a 0 p 1 t 1 a 1 i 2 r 2 r 1 r 0 i 2 = i t 2 seed jump l b

11 An Algorithm to Find Implicit Flows datatype Instruction = ASG of string * string list PHI of string list * string list list datatype DomTree = BR of Instruction list * string * DomTree list * DomTree JMP of Instruction list * DomTree list fun link [] _ = [] link _ "" = [] link ((ASG (a, _)) :: insts) lb = (lb, a) :: link insts lb link ((PHI (deflist, _)) :: insts) lb = (map (fn a => (lb, a)) link insts lb fun visit (JMP (instructions, [])) pred = link instructions pred visit (JMP (instructions, [child])) pred = link instructions visit child pred visit (BR (instructions, new_pred, children, ipdom)) pred = let fun visit_every [] = [] visit_every (child::rest) = if child = ipdom then visit child visit_every rest else visit child visit_every rest in link instructions visit_every children end This is our algorithm, in SML/NJ's syntax You do not have to understand it now. But it is premy short And goes down the programs' dominance tree And needs also the program's postdominance tree

12 Important: Dominance a b m n x y Node 'a' dominates node 'b', because any path from to 'b' goes across 'a'. Similarly, node 'b' post-dominates node 'a', because any (backwards) path from to 'a' must go across 'b'. Node n post-dominates node m, but m does not dominate n. Node x dominates node y, but y does not postdominate node x.

13 Stack of Predicates l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 We traverse the dominator tree, "remembering" the predicates that we find on the way. For instance, aper walking on the red path, we will have visited predicates b 0, b 1 and b 2. l 8 : p 0 = v[i] l 9 : len 0 = 0 l 23 : max r [0] = max l 24 : ret sum l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 23 : max r [0] = max l 24 : ret sum l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 19 : max 0 = len l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1 l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1 Control flow graph

14 Stack of Predicates l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 We "forget" a predicate p if (i) we are done visi+ng every child of b, the block where p is used in a branch, or (ii) we reach the basic block d that post-dominates b. l 8 : p 0 = v[i] l 9 : len 0 = 0 l 23 : max r [0] = max l 24 : ret sum l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 This block postominates this other block l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 23 : max r [0] = max l 24 : ret sum l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 19 : max 0 = len l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1 l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

15 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 stack = [] l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 l 23 : max r [0] = max l 24 : ret sum We start visi+ng the first basic block, which we shall call b 0-2. At the beginning, we have seen no predicate. This block, b 0-2, terminates with an uncondi+onal jump; hence, we do not have to stack up a new predicate, given that there is none. l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

16 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 stack = [] l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 l 23 : max r [0] = max l 24 : ret sum We now visit b 3-7, again, with an empty stack. Because the stack is empty, there are no links to create. But this block terminates with a branch br b 0 l 8, l 23. Thus, we push b 0 up. In this way, we will link b 0 to the instruc+ons defined in the children of b 3-7. l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

17 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 stack = [b 0 ] l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 l 23 : max r [0] = max l 24 : ret sum We are now visi+ng the children of b 3-7. The order in which we visit these children is not important. Both are being visited with the predicate {b 0 }. The important event that will take place soon is the linking of nodes... l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

18 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 stack = [b 0 ] stack = [] l 23 : max r [0] = max l 24 : ret sum We will create implicit flow edges (b 0, p 0 ) and (b 0, len 0 ). However, we will not create the edge (b 0, max r ). This happens because b is the post-dominator of b 3-7, the block where b 0 is defined. When we visit b 23-24, coming out of b 3-7, we pop b 0 before moving further down. l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

19 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 8 : p 0 = v[i] l 9 : len 0 = 0 stack = [b 0 ] l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 stack = [b 1, b 0 ] stack = [b 0 ] l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 23 : max r [0] = max l 24 : ret sum Once we visit b 10_14, there are two things that we must do. First, we must link variables defined there to b 0, which is the current predicate. Second, we must update the current predicate to visit b 15_16. No+ce that this upda+ng happens only to visit b 15_16. We visit b 17_18 with the old predicate {b 0 }, because this block post-dominates b 10_14. l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

20 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 8 : p 0 = v[i] l 9 : len 0 = 0 l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 stack = [b 1, b 0 ] stack = [b 0 ] l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 23 : max r [0] = max l 24 : ret sum We link every variable defined at b with b 1, because this is the current predicate once b is visited. From b we are done on this side of the tree, because this block has no children. Once we visit b 17_18 we link every instruc+on in this block to b 0, and not b 1, because b 0 is the current predicate when b 17_18 is visited. We do not have to stack b 1 up to visit b 17_18, because this block post-dominates b 10_14. l 19 : max 0 = len l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

21 l 0 : i 0 = 0 l 1 : sum 0 = 0 l 2 : max 0 = 0 l 8 : p 0 = v[i] l 9 : len 0 = 0 l 3 : i =!(i 0, i 1 ) l 4 : max =!(max 0, max 1 ) l 5 : sum =!(sum 0, sum 1 ) l 6 : b 0 = (i < N)? l 7 : br b 0 l 8, l 23 l 23 : max r [0] = max l 24 : ret sum Aper visi+ng b and b we are done. We link variables in b to b 2, the current predicate, and we link variables in b to b 0, the current predicate when that block is visited. Given that we have no more blocks to visit, we are done! l 11 : len =!(len 0, len 1 ) l 15 : len 1 = len + 1 l 10 : p =!(p 0, p 1 ) l 11 : len =!(len 0, len 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 14 : br b 1 l 15, l 17 l 10 : p =!(p 0, p 1 ) l 12 : t = p[0] l 13 : b 1 = (t!= '\0')? l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 15 : len 1 = len + 1 l 16 : p 1 = p + 1 l 17 : b 2 = (len < max)? l 18 : br b 2 l 19, l 20 l 19 : max 0 = len stack = [b 2, b 0 ] l 19 : max 0 = len stack = [b 0 ] l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1 l 7 : br b 0 l 8, l 23 l 20 : max 1 =!(max 0, max) l 21 : sum 1 = sum + len l 22 : i 1 = i + 1

22 Contribu+ons I We avoid worst cases in the technique used by Ferrante et al to to handle nests of repeat loops and ladder CFGs p v 1 v v v 0 p 3 v 2 v 2 v 3 v 3 p 2 p 2 v 4 v 4 v 5 v 5 p 1 v 6 p 1 v 6 v 7 v 8 v 9 v 10 v 7 v 8 v 9 v 10 Ferrante et al This paper

23 Contribu+ons I We avoid worst cases in the technique used by Ferrante et al to to handle nests of repeat loops (R) and ladder CFGs (L) 900" 800" 700" 600" 500" 400" 300" 200" 100" 0" 5" 6" 7" 8" 9" 10" 11" 12" 13" 14" 15" 16" 17" 18" 19" 20" R+Flow" R+Ferrante" L+Flow" L+Ferrante"

24 Contribu+ons II We reduce the complexity of implemen+ng Hunt and Sands' System of Security Types. l 1 : w = ; l 2 : x = ; l 3 : y = ; l 4 : z = l 5 : p = use(x) l 6 : branch p l 9 l 7 : y = use(y); l 8 : w = use(z) l 9 : p = use(x); l 10 : branch p l exit l 11 : z = use(z, w); l 12 : x = use(z); l 13 : z = use(x) p w x y z 1-2: [, L,,, ] 2-3: [, L, L,, ] 3-4: [, L, L, L, ] 4-5: [, L, L, L, H] 5-6: [L, L, L, L, H] 6-7: [L, L, L, L, H] 7-8: [L, L, L, L, H] 8-9: [L, H, L, L, H] 6-9: [L, L, L, L, H] 9-10: [H, H, H, L, H] 10-11: [H, H, H, L, H] 11-12: [H, H, H, L, H] 12-13: [H, H, H, L, H] 13-9: [H, H, H, L, H]

25 Contribu+ons II We reduce the complexity of implemen+ng Hunt and Sands' System of Security Types. l 1 : w 0 = ; l 2 : x 0 = ; l 3 : y 0 = ; l 4 : z 0 = y 0 l 5 : p 0 = use(x 0 ) l 6 : branch p 0 l 9 y 1 y 2 l 7 : y 1 = use(y 0 ); l 8 : w 1 = use(z 0 ) p 0 x 0 x 1 l 9 : [y 2 = ϕ(y 0, y 1 ); w 2 = ϕ(w 0, w 1 )] w 1 z 0 p 1 l 10 : [x 1 = ϕ(x 0, x 2 ); z 1 = ϕ(z 0, z 3 )] w 2 z 1 z 3 l 11 : p 1 = use(x 1 ); l 12 : branch p 1 l exit l 13 : z 2 = use(z 1, w 2 ); l 14 : x 2 = use(z 2 ); l 15 : z 3 = use(x 2 ) w 0 z 2 x 2

26 Contribu+ons III We have detected security issues in real-world crypto libraries, such as TrueCrypt and OpenSSL. l o w T r a c k e r Making programs safe through static flow analyses Define sources and sinks of informa+on Finds paths between sources and sinks Available on-line at hmp://cuda.dcc.ufmg.br/flowtracker

27 Isochronous Code A program P is isochronous with regard to an input i if P always take the same +me to execute, independent on the value of i. Is this program isochronous with regard to input pw? int foo(char* pw, char* in) {! int i;! for (i = 0; i < 3; i++) {! if (pw[i]!= in[i]) {! return 0;! }! }! return 1;! }!

28 Isochronous Programs A program P is isochronous with regard to an input i if P always take the same +me to execute, independent on the value of i. What about this new program? Is it isochronous with regard to input p? int foo(char* pw, char* in) {! int p0 = pw[0] == in[0];! int p1 = pw[1] == in[1];! int p2 = pw[2] == in[2];! return p0 && p1 && p2;! }!

29 Low-Level Analysis int foo(char* pw, char* in) {! int p0 = pw[0] == in[0];! int p1 = pw[1] == in[1];! int p2 = pw[2] == in[2];! return p0 && p1 && p2;! }! entry: %arrayidx = getelementptr inbounds i8* %pw, i64 0 %tmp = load i8* %arrayidx, align 1 %conv = sext i8 %tmp to i32 %arrayidx1 = getelementptr inbounds i8* %in, i64 0 %tmp1 = load i8* %arrayidx1, align 1 %conv2 = sext i8 %tmp1 to i32 %cmp = icmp eq i32 %conv, %conv2 br i1 %cmp, label %land.lhs.true, label %land.end land.lhs.true: %arrayidx4 = getelementptr inbounds i8* %pw, i64 1 %tmp2 = load i8* %arrayidx4, align 1 %conv5 = sext i8 %tmp2 to i32 %arrayidx6 = getelementptr inbounds i8* %in, i64 1 %tmp3 = load i8* %arrayidx6, align 1 %conv7 = sext i8 %tmp3 to i32 %cmp8 = icmp eq i32 %conv5, %conv7 br i1 %cmp8, label %land.rhs, label %land.end T T F F land.rhs: %arrayidx10 = getelementptr inbounds i8* %pw, i64 2 %tmp4 = load i8* %arrayidx10, align 1 %conv11 = sext i8 %tmp4 to i32 %arrayidx12 = getelementptr inbounds i8* %in, i64 2 %tmp5 = load i8* %arrayidx12, align 1 %conv13 = sext i8 %tmp5 to i32 %cmp14 = icmp eq i32 %conv11, %conv13 br label %land.end land.end: %tmp6 = phi i1 [ false, %land.lhs.true ], [ false, %entry ], [ %cmp14,... %land.rhs ] %land.ext = zext i1 %tmp6 to i32 ret i32 %land.ext

30 Compiling Isochronous Code Compiler writers usually do not worry about preserving the isochronous behavior of code. Yet, current tools that detect +me-based side channels operate at the source code level. We claim that this kind of informa+on flow analysis should be performed at lower levels, for it is the implementa.on, not the abstract design of a crypto algorithm that will be running in produc+on.

31 What FlowTracker does entry: %retval = alloca i32, align 4 %argc.addr = alloca i32, align 4 %argv.addr = alloca i8**, align 8 %sum = alloca i32, align 4 %p = alloca i8*, align 8 %p2 = alloca i8*, align 8 %p14 = alloca i8*, align 8 store i32 0, i32* %retval store i32 %argc, i32* %argc.addr, align 4 store i8** %argv, i8*** %argv.addr, align 8 store i32 0, i32* %sum, align 4 %0 = load i32* %argc.addr, align 4 switch i32 %0, label %sw.epilog [ i32 1, label %sw.bb i32 2, label %sw.bb1 i32 3, label %sw.bb13 ] sw.bb: br label %L0 def sw.bb1: %8 = load i8*** %argv.addr, align 8 %arrayidx3 = getelementptr inbounds i8** %8, i64 0 %9 = load i8** %arrayidx3, align 8 store i8* %9, i8** %p2, align 8 br label %for.cond4 for.cond4: %10 = load i8** %p2, align 8 %cmp5 = icmp ne i8* %10, null br i1 %cmp5, label %for.body7, label %for.end12 for.body7: %11 = load i8** %p2, align 8 %12 = load i8* %11, align 1 %conv8 = sext i8 %12 to i32 %13 = load i32* %sum, align 4 %add9 = add nsw i32 %13, %conv8 store i32 %add9, i32* %sum, align 4 br label %for.inc10 for.inc10: %14 = load i8** %p2, align 8 %incdec.ptr11 = getelementptr inbounds i8* %14, i32 1 store i8* %incdec.ptr11, i8** %p2, align 8 br label %for.cond4 T F for.end12: %15 = load i32* %sum, align 4 %rem = srem i32 %15, 2 %tobool = icmp ne i32 %rem, 0 br i1 %tobool, label %if.then, label %if.else T if.then: br label %L0 F if.else: br label %L1 sw.bb13: br label %L1 FlowTracker points out if secret informa+on controls: The outcome of condi+onal branches The indices of memory addresses L0: %1 = load i8*** %argv.addr, align 8 %arrayidx = getelementptr inbounds i8** %1, i64 0 %2 = load i8** %arrayidx, align 8 store i8* %2, i8** %p, align 8 br label %for.cond L1: %16 = load i8*** %argv.addr, align 8 %arrayidx15 = getelementptr inbounds i8** %16, i64 0 %17 = load i8** %arrayidx15, align 8 store i8* %17, i8** %p14, align 8 br label %for.cond16 for.cond: %3 = load i8** %p, align 8 %cmp = icmp ne i8* %3, null br i1 %cmp, label %for.body, label %for.end for.cond16: %18 = load i8** %p14, align 8 %cmp17 = icmp ne i8* %18, null br i1 %cmp17, label %for.body19, label %for.end24 T F T F for.body: %4 = load i8** %p, align 8 %5 = load i8* %4, align 1 %conv = sext i8 %5 to i32 %6 = load i32* %sum, align 4 %add = add nsw i32 %6, %conv store i32 %add, i32* %sum, align 4 br label %for.inc for.end: br label %sw.epilog for.body19: %19 = load i8** %p14, align 8 %20 = load i8* %19, align 1 %conv20 = sext i8 %20 to i32 %21 = load i32* %sum, align 4 %add21 = add nsw i32 %21, %conv20 store i32 %add21, i32* %sum, align 4 br label %for.inc22 for.end24: br label %sw.epilog for.inc: %7 = load i8** %p, align 8 %incdec.ptr = getelementptr inbounds i8* %7, i32 1 store i8* %incdec.ptr, i8** %p, align 8 br label %for.cond sw.epilog: %23 = load i32* %sum, align 4 ret i32 %23 for.inc22: %22 = load i8** %p14, align 8 %incdec.ptr23 = getelementptr inbounds i8* %22, i32 1 store i8* %incdec.ptr23, i8** %p14, align 8 br label %for.cond16

32 Run+me of FlowTracker 1.E+06' 1.E+05' 1.E+04' 1.E+03' 1.E+02' 0' 1' 2' 3' 4' 5' 6' 7' 8' 9' 10' 11' 12' 13' 14' 15' 16' 17' 18' 19' 20' 21' 22' 23' 24' 25' 26' 27' 28' 29' 30' Number'of'Instruc<ons' Data'Edges' Control'Edges' Time(ms)' Each +ck in the X-axis is a different benchmark. FlowTracker inserts 1,11M control edges in gcc, our largest benchmark, which has 1.25M variables. Behavior is linear (R 2 = 0.98)

33 Generality 100" Address Leak: 52% Buffer Overflow: 53% Integer Overflow: 69% 75" 50" 25" 0" perl" bzip2" mcf" gobmk" hmmer" sjeng" libq" h264" omnet" astar" xalanc" gcc" Address"Leak" Tainted"Flow" Integer"Overflow" Address leak: can an adversary infer the value of a pointer? Buffer overflow: can an adversary control the size of allocated memory, or indices of arrays? Integer Overflow: is there memory indexed by arithme+c opera+ons that may overflow?

34 Issues in Real-World Code We have applied FlowTracker on GLS254. Four warnings. Issues discovered by FlowTracker: A +ming-variant branch which depended on secret informa+on flow but in prac+ce was never taken. The fix involved removing the branch altogether. Variable-+me code that was not called anywhere but was s+ll pointed out. The fix was dele+ng the affected code. No issue found in NaCl : Ellip+c-curve Diffie-Hellman secret sharing using GLS binary curve (L^2 + LZ + az^2)x^2 = X^4 + bz^4 defined over GF(2^254) and implemented with lambda-projec+ve coordinates (X, L, Z).

35

36

37 Conclusion Sparse implementa+on of informa+on flows Track flow between values, not between instruc+ons Web: Video tutorial: Bruno Rodrigues - brunors172@gmail.com! Diego Aranha - dfaranha@gmail.com! Fernando Pereira - fernando@dcc.ufmg.br (that's me!) We are looking for use-cases, and will be happy to help people to understand and use our tool

Tainted Flow Analysis on e-ssaform

Tainted Flow Analysis on e-ssaform Tainted Flow Analysis on e-ssaform Programs Andrei Rimsa, Marcelo d Amorim and Fernando M. Q. Pereira The Objective of this work is to detect security vulnerabilities in programs via static analysis Vulnerabilities

More information

COSE312: Compilers. Lecture 17 Intermediate Representation (2)

COSE312: Compilers. Lecture 17 Intermediate Representation (2) COSE312: Compilers Lecture 17 Intermediate Representation (2) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 17 May 31, 2017 1 / 19 Common Intermediate Representations Three-address code

More information

What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed

What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed Another Form of Data-Flow Analysis Propagation of values for a variable reference, where is the value produced? for a variable definition, where is the value consumed? Possible answers reaching definitions,

More information

Computing Static Single Assignment (SSA) Form

Computing Static Single Assignment (SSA) Form Computing Static Single Assignment (SSA) Form Overview What is SSA? Advantages of SSA over use-def chains Flavors of SSA Dominance frontiers revisited Inserting φ-nodes Renaming the variables Translating

More information

INF2220: algorithms and data structures Series 1

INF2220: algorithms and data structures Series 1 Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)

More information

CSC D70: Compiler Optimization Static Single Assignment (SSA)

CSC D70: Compiler Optimization Static Single Assignment (SSA) CSC D70: Compiler Optimization Static Single Assignment (SSA) Prof. Gennady Pekhimenko University of Toronto Winter 08 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip

More information

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation -74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation

More information

Objec&ves. Review. Data structure: Heaps Data structure: Graphs. What is a priority queue? What is a heap?

Objec&ves. Review. Data structure: Heaps Data structure: Graphs. What is a priority queue? What is a heap? Objec&ves Data structure: Heaps Data structure: Graphs Submit problem set 2 1 Review What is a priority queue? What is a heap? Ø Proper&es Ø Implementa&on What is the process for finding the smallest element

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Models of Computation. by Costas Busch, LSU

Models of Computation. by Costas Busch, LSU Models of Computation by Costas Busch, LSU 1 Computation CPU memory 2 temporary memory input memory CPU output memory Program memory 3 Example: f ( x) x 3 temporary memory input memory Program memory compute

More information

Verifying the LLVM. Steve Zdancewic DeepSpec Summer School 2017

Verifying the LLVM. Steve Zdancewic DeepSpec Summer School 2017 Verifying the LLVM Steve Zdancewic DeepSpec Summer School 2017 Vminus OperaAonal SemanAcs Only 5 kinds of instrucaons: Binary arithmeac Memory Load Memory Store Terminators Phi nodes What is the state

More information

A Functional Perspective

A Functional Perspective A Functional Perspective on SSA Optimization Algorithms Patryk Zadarnowski jotly with Manuel M. T. Chakravarty Gabriele Keller 19 April 2004 University of New South Wales Sydney THE PLAN ➀ Motivation an

More information

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) Objectives Recall that decidable languages are languages that can be decided by TM (that means,

More information

Register Alloca.on. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class

Register Alloca.on. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class Register Alloca.on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class 1 Register Alloca.on Intermediate code uses unlimited temporaries Simplifying code genera.on and op.miza.on

More information

Lecture 11: Data Flow Analysis III

Lecture 11: Data Flow Analysis III CS 515 Programming Language and Compilers I Lecture 11: Data Flow Analysis III (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang

More information

CSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1

CSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1 CSE P 501 Compilers Value Numbering & Op;miza;ons Hal Perkins Winter 2016 UW CSE P 501 Winter 2016 S-1 Agenda Op;miza;on (Review) Goals Scope: local, superlocal, regional, global (intraprocedural), interprocedural

More information

Path Testing and Test Coverage. Chapter 9

Path Testing and Test Coverage. Chapter 9 Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test

More information

Tutorial 4. Dynamic Set: Amortized Analysis

Tutorial 4. Dynamic Set: Amortized Analysis Tutorial 4 Dynamic Set: Amortized Analysis Review Binary tree Complete binary tree Full binary tree 2-tree P115 Unlike common binary tree, the base case is not an empty tree, but a external node Heap Binary

More information

Path Testing and Test Coverage. Chapter 9

Path Testing and Test Coverage. Chapter 9 Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test

More information

: Advanced Compiler Design Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming

: Advanced Compiler Design Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming 263-2810: Advanced Compiler Design 3.3.2 Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming Thomas R. Gross Computer Science Department ETH Zurich, Switzerland

More information

Construction of Static Single-Assignment Form

Construction of Static Single-Assignment Form COMP 506 Rice University Spring 2018 Construction of Static Single-Assignment Form Part II source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all

More information

Material Covered on the Final

Material Covered on the Final Material Covered on the Final On the final exam, you are responsible for: Anything covered in class, except for stories about my good friend Ken Kennedy All lecture material after the midterm ( below the

More information

CA Compiler Construction

CA Compiler Construction CA4003 - Compiler Construction Code Generation to MIPS David Sinclair Code Generation The generation o machine code depends heavily on: the intermediate representation;and the target processor. We are

More information

Lecture 4 Introduc-on to Data Flow Analysis

Lecture 4 Introduc-on to Data Flow Analysis Lecture 4 Introduc-on to Data Flow Analysis I. Structure of data flow analysis II. Example 1: Reaching defini?on analysis III. Example 2: Liveness analysis IV. Generaliza?on 15-745: Intro to Data Flow

More information

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis CMSC 631 Program Analysis and Understanding Spring 2013 Data Flow Analysis Data Flow Analysis A framework for proving facts about programs Reasons about lots of little facts Little or no interaction between

More information

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park 1617 Preview Data Structure Review COSC COSC Data Structure Review Linked Lists Stacks Queues Linked Lists Singly Linked List Doubly Linked List Typical Functions s Hash Functions Collision Resolution

More information

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes. Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci

More information

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis Motivation Introduction to Algorithms Hash Tables CSE 680 Prof. Roger Crawfis Arrays provide an indirect way to access a set. Many times we need an association between two sets, or a set of keys and associated

More information

Programming Language Concepts, CS2104 Lecture 3

Programming Language Concepts, CS2104 Lecture 3 Programming Language Concepts, CS2104 Lecture 3 Statements, Kernel Language, Abstract Machine 31 Aug 2007 CS2104, Lecture 3 1 Reminder of last lecture Programming language definition: syntax, semantics

More information

Space-aware data flow analysis

Space-aware data flow analysis Space-aware data flow analysis C. Bernardeschi, G. Lettieri, L. Martini, P. Masci Dip. di Ingegneria dell Informazione, Università di Pisa, Via Diotisalvi 2, 56126 Pisa, Italy {cinzia,g.lettieri,luca.martini,paolo.masci}@iet.unipi.it

More information

Timeline of a Vulnerability

Timeline of a Vulnerability Timeline of a Vulnerability Is this all a conspiracy? Vulnerability existed for many years 1 Daniel Gruss, Moritz Lipp, Michael Schwarz www.iaik.tugraz.at Timeline of a Vulnerability Is this all a conspiracy?

More information

Lecture 10: Data Flow Analysis II

Lecture 10: Data Flow Analysis II CS 515 Programming Language and Compilers I Lecture 10: Data Flow Analysis II (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang

More information

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ; 1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).

More information

Chapter 5. Finite Automata

Chapter 5. Finite Automata Chapter 5 Finite Automata 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical

More information

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 )

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 ) CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26 Homework #2 ( Due: Nov 8 ) Task 1. [ 80 Points ] Average Case Analysis of Median-of-3 Quicksort Consider the median-of-3 quicksort algorithm

More information

Principles of Program Analysis: Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

Unit 8: Sequ. ential Circuits

Unit 8: Sequ. ential Circuits CPSC 121: Models of Computation Unit 8: Sequ ential Circuits Based on slides by Patrice Be lleville and Steve Wolfman Pre-Class Learning Goals By the start of class, you s hould be able to Trace the operation

More information

Introduction to Computing II (ITI 1121) FINAL EXAMINATION

Introduction to Computing II (ITI 1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification

More information

6.001 Recitation 22: Streams

6.001 Recitation 22: Streams 6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris

More information

Queues. Principles of Computer Science II. Basic features of Queues

Queues. Principles of Computer Science II. Basic features of Queues Queues Principles of Computer Science II Abstract Data Types Ioannis Chatzigiannakis Sapienza University of Rome Lecture 9 Queue is also an abstract data type or a linear data structure, in which the first

More information

CS361 Homework #3 Solutions

CS361 Homework #3 Solutions CS6 Homework # Solutions. Suppose I have a hash table with 5 locations. I would like to know how many items I can store in it before it becomes fairly likely that I have a collision, i.e., that two items

More information

Compiler Design Spring 2017

Compiler Design Spring 2017 Compiler Design Spring 2017 8.5 Reaching definitions Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Admin issues Brief reminder: Code review takes place today @ 15:15 You

More information

Information Flow Analysis via Path Condition Refinement

Information Flow Analysis via Path Condition Refinement Information Flow Analysis via Path Condition Refinement Mana Taghdiri, Gregor Snelting, Carsten Sinz Karlsruhe Institute of Technology, Germany FAST September 16, 2010 KIT University of the State of Baden-Wuerttemberg

More information

Dynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007

Dynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007 Dynamic Noninterference Analysis Using Context Sensitive Static Analyses Gurvan Le Guernic July 14, 2007 1 Abstract This report proposes a dynamic noninterference analysis for sequential programs. This

More information

Automatic Verification of Parameterized Data Structures

Automatic Verification of Parameterized Data Structures Automatic Verification of Parameterized Data Structures Jyotirmoy V. Deshmukh, E. Allen Emerson and Prateek Gupta The University of Texas at Austin The University of Texas at Austin 1 Outline Motivation

More information

Control Dependence. Stanford University CS243 Winter 2006 Wei Li 1

Control Dependence. Stanford University CS243 Winter 2006 Wei Li 1 Control Dependence Wei Li 1 Control Dependence Introduction Formal Definition Optimal Control Dependence Computation 2 xample START a b c d CFG ND b is control dependent on a c is control dependent on

More information

Solutions. Prelim 2[Solutions]

Solutions. Prelim 2[Solutions] Prelim [Solutions]. Short Answer [ pts] (a) [ pts] A traversal of an expression tree produces the string + + 3. i. What kind of traversal is it? Preorder; the operator is printed before the operands. ii.

More information

INF421, Lecture 2 Queues

INF421, Lecture 2 Queues INF421, Lecture 2 Queues Leo Liberti LIX, École Polytechnique, France INF421, Lecture 2 p. 1 Course Objective: to teach you some data structures and associated algorithms Evaluation: TP noté en salle info

More information

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction) CS5371 Theory of Computation Lecture 14: Computability V (Prove by Reduction) Objectives This lecture shows more undecidable languages Our proof is not based on diagonalization Instead, we reduce the problem

More information

Advanced Implementations of Tables: Balanced Search Trees and Hashing

Advanced Implementations of Tables: Balanced Search Trees and Hashing Advanced Implementations of Tables: Balanced Search Trees and Hashing Balanced Search Trees Binary search tree operations such as insert, delete, retrieve, etc. depend on the length of the path to the

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. May 11/13, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Programming with classical quantum datatypes

Programming with classical quantum datatypes Programming with classical quantum datatypes Robin Cockett & Brett Giles (robin,gilesb)@cpsc.ucalgary.ca University of Calgary FMCS 2006, Programming with classical quantum datatypes p. 1/49 Yet another

More information

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies Flow Interfaces Compositional Abstractions of Concurrent Data Structures Siddharth Krishna, Dennis Shasha, and Thomas Wies Background Verifying programs, separation logic, inductive predicates Verifying

More information

Data Structures and Algorithms " Search Trees!!

Data Structures and Algorithms  Search Trees!! Data Structures and Algorithms " Search Trees!! Outline" Binary Search Trees! AVL Trees! (2,4) Trees! 2 Binary Search Trees! "! < 6 2 > 1 4 = 8 9 Ordered Dictionaries" Keys are assumed to come from a total

More information

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 9, 2019 Please don t print these lecture notes unless you really need to!

More information

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies Flow Interfaces Compositional Abstractions of Concurrent Data Structures Siddharth Krishna, Dennis Shasha, and Thomas Wies Background Verifying programs, separation logic, inductive predicates Slides courtesy

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow

More information

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 11, 2015 Please don t print these lecture notes unless you really need to!

More information

Timeline of a Vulnerability

Timeline of a Vulnerability Introduction Timeline of a Vulnerability Is this all a conspiracy? Vulnerability existed for many years 2 Michael Schwarz (@misc0110) www.iaik.tugraz.at Timeline of a Vulnerability Is this all a conspiracy?

More information

CS213d Data Structures and Algorithms

CS213d Data Structures and Algorithms CS21d Data Structures and Algorithms Heaps and their Applications Milind Sohoni IIT Bombay and IIT Dharwad March 22, 2017 1 / 18 What did I see today? March 22, 2017 2 / 18 Heap-Trees A tree T of height

More information

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of

More information

Math Models of OR: Branch-and-Bound

Math Models of OR: Branch-and-Bound Math Models of OR: Branch-and-Bound John E. Mitchell Department of Mathematical Sciences RPI, Troy, NY 12180 USA November 2018 Mitchell Branch-and-Bound 1 / 15 Branch-and-Bound Outline 1 Branch-and-Bound

More information

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries Data-Flow Analysis Compiler Design CSE 504 1 Preliminaries 2 Live Variables 3 Data Flow Equations 4 Other Analyses Last modifled: Thu May 02 2013 at 09:01:11 EDT Version: 1.3 15:28:44 2015/01/25 Compiled

More information

Appendix of Computational Protein Design Using AND/OR Branch and Bound Search

Appendix of Computational Protein Design Using AND/OR Branch and Bound Search Appendix of Computational Protein Design Using AND/OR Branch and Bound Search Yichao Zhou 1, Yuexin Wu 1, and Jianyang Zeng 1,2, 1 Institute for Interdisciplinary Information Sciences, Tsinghua University,

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Language (ver1) Lambda calculus with boolean values t ::= x variable x : T.t abstraction tt application true false boolean values if ttt conditional expression Values v ::=

More information

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1 Data Flow Analysis Lecture 6 ECS 240 ECS 240 Data Flow Analysis 1 The Plan Introduce a few example analyses Generalize to see the underlying theory Discuss some more advanced issues ECS 240 Data Flow Analysis

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. April 18/ May 2, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Algorithms and Data S tructures Structures Complexity Complexit of Algorithms Ulf Leser

Algorithms and Data S tructures Structures Complexity Complexit of Algorithms Ulf Leser Algorithms and Data Structures Complexity of Algorithms Ulf Leser Content of this Lecture Efficiency of Algorithms Machine Model Complexity Examples Multiplication of two binary numbers (unit cost?) Exact

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 12

CMSC 132, Object-Oriented Programming II Summer Lecture 12 CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 12 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 12.1 Trees

More information

Topics on Compilers

Topics on Compilers Assignment 2 4541.775 Topics on Compilers Sample Solution 1. Test for dependences on S. Write down the subscripts. Which positions are separable, which are coupled? Which dependence test would you apply

More information

Resources Control Graphs

Resources Control Graphs Resources Control Graphs Jean-Yves Moyen LIPN CNRS GeoCal ICC p. Motivations Programs analysis deal about uniform properties: Do all the executions terminate? Are all the executions performed within a

More information

Topic-I-C Dataflow Analysis

Topic-I-C Dataflow Analysis Topic-I-C Dataflow Analysis 2012/3/2 \course\cpeg421-08s\topic4-a.ppt 1 Global Dataflow Analysis Motivation We need to know variable def and use information between basic blocks for: constant folding dead-code

More information

CSCE 551: Chin-Tser Huang. University of South Carolina

CSCE 551: Chin-Tser Huang. University of South Carolina CSCE 551: Theory of Computation Chin-Tser Huang huangct@cse.sc.edu University of South Carolina Church-Turing Thesis The definition of the algorithm came in the 1936 papers of Alonzo Church h and Alan

More information

Imperative Insertion Sort

Imperative Insertion Sort Imperative Insertion Sort Christian Sternagel April 17, 2016 Contents 1 Looping Constructs for Imperative HOL 1 1.1 While Loops............................ 1 1.2 For Loops.............................

More information

MIT Loop Optimizations. Martin Rinard

MIT Loop Optimizations. Martin Rinard MIT 6.035 Loop Optimizations Martin Rinard Loop Optimizations Important because lots of computation occurs in loops We will study two optimizations Loop-invariant code motion Induction variable elimination

More information

Graph Search Howie Choset

Graph Search Howie Choset Graph Search Howie Choset 16-11 Outline Overview of Search Techniques A* Search Graphs Collection of Edges and Nodes (Vertices) A tree Grids Stacks and Queues Stack: First in, Last out (FILO) Queue: First

More information

Register Allocation. Maryam Siahbani CMPT 379 4/5/2016 1

Register Allocation. Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Intermediate code uses unlimited temporaries Simplifying code generation and optimization Complicates final translation to assembly

More information

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions? Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques AVL Trees Manolis Koubarakis 1 AVL Trees We will now introduce AVL trees that have the property that they are kept almost balanced but not completely balanced. In this way we have O(log n) search time

More information

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Copyright c 2015 Andrew Klapper. All rights reserved. 1. For the functions satisfying the following three recurrences, determine which is the

More information

Binary Search Trees. Motivation

Binary Search Trees. Motivation Binary Search Trees Motivation Searching for a particular record in an unordered list takes O(n), too slow for large lists (databases) If the list is ordered, can use an array implementation and use binary

More information

Equalities and Uninterpreted Functions. Chapter 3. Decision Procedures. An Algorithmic Point of View. Revision 1.0

Equalities and Uninterpreted Functions. Chapter 3. Decision Procedures. An Algorithmic Point of View. Revision 1.0 Equalities and Uninterpreted Functions Chapter 3 Decision Procedures An Algorithmic Point of View D.Kroening O.Strichman Revision 1.0 Outline Decision Procedures Equalities and Uninterpreted Functions

More information

INTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course.

INTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course. C PROGRAMMING 1 INTRODUCTION This is not a full c-programming course. It is not even a full 'Java to c' programming course. 2 LITTERATURE 3. 1 FOR C-PROGRAMMING The C Programming Language (Kernighan and

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We now prove that a language is generated by some CFG if and only if it is accepted

More information

Introduction to Computing II (ITI1121) FINAL EXAMINATION

Introduction to Computing II (ITI1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification

More information

GRIDLang. Move-Driven Game Programming Language Final Report. May 10, 2017

GRIDLang. Move-Driven Game Programming Language Final Report. May 10, 2017 GRIDLang Move-Driven Game Programming Language Final Report Akshay Nagpal (an2756) Parth Panchmatia (psp2137) Dhruv Shekhawat (ds3512) Sagar Damani (ssd2144) May 10, 2017 1 Contents 1 Introduction 4 2

More information

SOLUTION: SOLUTION: SOLUTION:

SOLUTION: SOLUTION: SOLUTION: Convert R and S into nondeterministic finite automata N1 and N2. Given a string s, if we know the states N1 and N2 may reach when s[1...i] has been read, we are able to derive the states N1 and N2 may

More information

Automata-Theoretic Model Checking of Reactive Systems

Automata-Theoretic Model Checking of Reactive Systems Automata-Theoretic Model Checking of Reactive Systems Radu Iosif Verimag/CNRS (Grenoble, France) Thanks to Tom Henzinger (IST, Austria), Barbara Jobstmann (CNRS, Grenoble) and Doron Peled (Bar-Ilan University,

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Based

More information

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation

More information

System Data Bus (8-bit) Data Buffer. Internal Data Bus (8-bit) 8-bit register (R) 3-bit address 16-bit register pair (P) 2-bit address

System Data Bus (8-bit) Data Buffer. Internal Data Bus (8-bit) 8-bit register (R) 3-bit address 16-bit register pair (P) 2-bit address Intel 8080 CPU block diagram 8 System Data Bus (8-bit) Data Buffer Registry Array B 8 C Internal Data Bus (8-bit) F D E H L ALU SP A PC Address Buffer 16 System Address Bus (16-bit) Internal register addressing:

More information

Improper Nesting Example

Improper Nesting Example Improper Nesting Example One of the limits on the use of parbegin/parend, and any related constructs, is that the program involved must be properly nested. Not all programs are. For example, consider the

More information

CTL satisfability via tableau A C++ implementation

CTL satisfability via tableau A C++ implementation CTL satisfability via tableau A C++ implementation Nicola Prezza April 30, 2015 Outline 1 Introduction 2 Parsing 3 Data structures 4 Initial sets of labels and edges 5 Cull 6 Examples and benchmarks The

More information

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Language Processing Systems Prof. Mohamed Hamada Software Engineering La. The University of izu Japan Syntax nalysis (Parsing) 1. Uses Regular Expressions to define tokens 2. Uses Finite utomata to recognize

More information

Solutions to EoPL3 Exercises

Solutions to EoPL3 Exercises Solutions to EoPL3 Exercises Release 0.1.0 Cheng Lian May 16, 2017 Contents 1 Contents 3 2 Overview 29 i ii Author Cheng Lian Contents 1 2 Contents CHAPTER 1 Contents Chapter 1.

More information

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

More information