TALx86: A Realistic Typed Assembly Language

Slides:



Advertisements
Similar presentations
COS 441 Exam Stuff David Walker. TAL 2 Logistics take-home exam will become available on the course web site Jan write down when you download &
Advertisements

Type Analysis and Typed Compilation Stephanie Weirich Cornell University.
Coalescing Register Allocation CS153: Compilers Greg Morrisett.
Foundational Certified Code in a Metalogical Framework Karl Crary and Susmit Sarkar Carnegie Mellon University.
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
The Design and Implementation of a Certifying Compiler [Necula, Lee] A Certifying Compiler for Java [Necula, Lee et al] David W. Hill CSCI
Extensible Verification of Untrusted Code Bor-Yuh Evan Chang, Adam Chlipala, Kun Gao, George Necula, and Robert Schneck May 14, 2004 OSQ Retreat Santa.
Typed Assembly Languages COS 441, Fall 2004 Frances Spalding Based on slides from Dave Walker and Greg Morrisett.
Survey of Typed Assembly Language (TAL) Introduction and Motivation –Conventional untyped compiler < Typed intermediate languages –Typed intermediate language.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
1 Function Calls Professor Jennifer Rexford COS 217 Reading: Chapter 4 of “Programming From the Ground Up” (available online from the course Web site)
Typed Memory Management in a Calculus of Capabilities David Walker (with Karl Crary and Greg Morrisett)
1 Enforcing Confidentiality in Low-level Programs Andrew Myers Cornell University.
1 A Dependently Typed Assembly Language Hongwei Xi University of Cincinnati and Robert Harper Carnegie Mellon University.
Proofs, Types, and Safe Mobile Code CoS 598E David Walker.
Programmability with Proof-Carrying Code George C. Necula University of California Berkeley Peter Lee Carnegie Mellon University.
Accessing parameters from the stack and calling functions.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
STAL David Walker (joint work with Karl Crary, Neal Glew and Greg Morrisett)
Language-Based Security Proof-Carrying Code Greg Morrisett Cornell University Thanks to G.Necula & P.Lee.
8/14/03ALADDIN REU Symposium Implementing TALT William Lovas with Karl Crary.
A Type System for Expressive Security Policies David Walker Cornell University.
Secure Certifying Compilation David Walker Cornell University What do you want to type check today?
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advanced Type Systems for Low-Level Languages Greg Morrisett Cornell University.
Scalable Certification for Typed Assembly Language Dan Grossman (with Greg Morrisett) Cornell University 2000 ACM SIGPLAN Workshop on Types in Compilation.
Previous Next 06/18/2000Shanghai Jiaotong Univ. Computer Science & Engineering Dept. C+J Software Architecture Shanghai Jiaotong University Author: Lu,
Typed Assembly Languages and Security Automatons Ben Watson The George Washington University CS 297 Security and Programming Languages June 2, 2005.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.1 Basics of Java Produced by Harvey Peters, 2008 Copyright.
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
Secure Compiler Seminar 4/11 Visions toward a Secure Compiler Toshihiro YOSHINO (D1, Yonezawa Lab.)
Compiler Construction Code Generation Activation Records
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
1 Assembly Language: Function Calls Jennifer Rexford.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
Course 150 Basic Computing Environment. Objective of course Familiar with Linux environment Objective of lecture: To understand basic terms like software,
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
Applications Active Web Documents Active Web Documents.
Recitation 3: Procedures and the Stack
Reading Condition Codes (Cont.)
Introduction to Operating Systems
Assembly language.
Introduction to programming languages, Algorithms & flowcharts
Data Transfers, Addressing, and Arithmetic
Types for Programs and Proofs
Introduction to programming languages, Algorithms & flowcharts
Introduction to Compilers Tim Teitelbaum
High-Level Language Interface
Recitation 2 – 2/4/01 Outline Machine Model
Introduction to programming languages, Algorithms & flowcharts
Computer Architecture and Assembly Language
Machine-Level Programming 4 Procedures
Introduction to Operating Systems
Security in Java Real or Decaf? cs205: engineering software
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Assembly Language Programming II: C Compiler Calling Sequences
Fundamentals of Computer Organisation & Architecture
Machine-Level Programming III: Procedures Sept 18, 2001
MIPS Procedure Calls CSE 378 – Section 3.
Lecture Topics: 11/1 General Operating System Concepts Processes
Multi-modules programming
The Design & Implementation of Hyperupcalls
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
Computer Organization and Assembly Language
Topic 2b ISA Support for High-Level Languages
Presentation transcript:

TALx86: A Realistic Typed Assembly Language Types inside TALx86: A Realistic Typed Assembly Language Dan Grossman, Fred Smith Cornell University Joint work with: Greg Morrisett, Karl Crary (CMU), Neal Glew, Richard Samuels, Dave Walker, Stephanie Weirich, Steve Zdancewic

Everyone wants extensibility: Web browser applets, plug-ins OS Kernel packet filters, device drivers “Active” networks service routines Databases extensible ADTs 1 May 1999 www.cs.cornell.edu/talc

Extension is written in a “safe” language: The Language Approach Extension is written in a “safe” language: Java, Modula-3, ML, Scheme Key point: language provides abstractions ADTs, closures, objects, modules, etc. Can be used to build fine-grained capabilities Host ensures code respects abstractions: Static checking (verification) Inserting dynamic checks (code-rewriting) 1 May 1999 www.cs.cornell.edu/talc

Example: Your Web Browser JVM verifier System Interface Low-Level IL Java Source Browser javac Optimizer JVM bytecode System Binary Binary 1 May 1999 www.cs.cornell.edu/talc

JVM Pros & Cons Pros: Cons: Portability Hype: $, tools, libraries, books, training Cons: Performance unsatisfying, even with off-line compilation Only really suitable for Java (or slight variants): relatively high-level instructions tailored to Java type system is Java specific and... 1 May 1999 www.cs.cornell.edu/talc

Large Trusted Computing Base No complete formal model JVM verifier System Interface Must insert right checks Low-Level IL Browser Good code  big optimizer  bugs in optimizer Optimizer System Binary Lots of “native” methods (i.e., not-safe code) Binary 1 May 1999 www.cs.cornell.edu/talc

Ideally: trusted computing base System Interface Your favorite language verifier System Binary Low-Level IL optimizer machine code 1 May 1999 www.cs.cornell.edu/talc

The Types Way trusted computing base TAL System Interface Your safe language verifier System Binary Typed Low-Level IL Verifier is a type-checker Type system flexible and expressive A useful instantiation of the “proof carrying code” framework Typed optimizer TAL 1 May 1999 www.cs.cornell.edu/talc

TALx86 in a Nutshell Most of the IA32 80x86 flat model assembly language Memory management primitives Sound type system Types for code, stacks, structs Other advanced features Future work (what we can’t do yet) 1 May 1999 www.cs.cornell.edu/talc

Primitive types: (e.g., int) Code types: {r1:t1,…,rn:tn} TALx86 Basics: Primitive types: (e.g., int) Code types: {r1:t1,…,rn:tn} “I’m code that requires register ri to have type ti before you can jump to me.” Code blocks are annotated with their types Think pre-condition Verify block assuming pre-condition 1 May 1999 www.cs.cornell.edu/talc

Sample Loop <n and retn addr as input> sum: <type> C: int sum(int n){ int s=0; while(!n) { s+=n; --n; } return n; TAL sketch: <n and retn addr as input> sum: <type> <initialize s> loop: <type> <add to s, decrement n> test: <type> <return if n is 0> 1 May 1999 www.cs.cornell.edu/talc

Verification sum: {ecx:int, ebx:{edx:int}} mov eax,0 jmp test loop:{ecx:int, ebx:{edx:int}, eax:int} add eax,ecx dec ecx test:{ecx:int, ebx:{edx:int}, eax:int} cmp ecx,0 jne loop mov edx,eax jmp ebx {ecx:int, ebx:{edx:int}, eax:int} OK: sub-type of type labeling test {ecx:int, ebx:{edx:int}, eax:int} {ecx:int, ebx:{edx:int}, eax:int} OK: sub-type of type labeling next block {ecx:int, ebx:{edx:int}, eax:int} OK: sub-type of type labeling loop {ecx:int, ebx:{edx:int}, eax:int, edx:int} OK: sub-type of {edx:int} -- type of ebx 1 May 1999 www.cs.cornell.edu/talc

Stacks & Procedures Stack Types (lists): s ::= nil | t::s | r where r is a stack type variable. Examples using C calling convention: int square(int); int mult(int,int); "r1 {esp: t1::int::r1} "r2 {esp: t2::int::int::r2} where where t1={eax: int, esp: int::r1} t2={eax: int, esp: int::int::r2} 1 May 1999 www.cs.cornell.edu/talc

r1 Stacks & Verification int t1 int int taft square: "r1 {esp: t1::int::r1} where t1={eax: int, esp: int::r1} push [esp+4] push [esp+8] call mult[with r2 = t1::int::r1] add esp,8 retn mult: "r2 {esp: t2::int::int::r2} where t2={eax: int, esp: int::int::r2} taft={eax:int, esp: int::int::t1::int::r1} int int {esp: t2::int::int::t1::int::r1} where t2={eax: int, esp: int::int::t1::int::r1} taft 1 May 1999 www.cs.cornell.edu/talc

Important Properties Abstraction Flexibility “Because the type of the rest of the stack is abstract the callee cannot read/write this portion of the stack” Flexibility Can encode and enforce many calling conventions (stack shape on return, callee-save, tail calls, etc.) 1 May 1999 www.cs.cornell.edu/talc

Callee-Save Example mult: "a "r2 {ebp: a, esp: t2::int::int::r2} where t2={ebp: a, eax: int, esp: int::int::r2} 1 May 1999 www.cs.cornell.edu/talc

Structs MALLOC “instruction” Goals: Prevent reading uninitialized fields Permit flexible scheduling of initialization MALLOC “instruction” returns uninitialized record Type of struct tracks initialization of fields Example: {ecx: int} MALLOC eax,8 [int,int] ; eax : ^*[intu, intu] mov [eax+0], ecx ; eax : ^*[intrw,intu] mov ecx, [eax+4] ; type error! 1 May 1999 www.cs.cornell.edu/talc

Much, much more Arrays (see next slide) Tagged Unions Displays, Exceptions [TIC’98] Static Data Modules and Interfaces [POPL’99] Run-time code generation [PEPM’99 Jim, Hornof] 1 May 1999 www.cs.cornell.edu/talc

Mis-features MALLOC and garbage collection in trusted computing base [POPL’99] No way to express aliasing No array bounds check elimination [Walker] Object/class support too primitive [Glew] 1 May 1999 www.cs.cornell.edu/talc

Summary and Conclusions We can type real machine code Potential for performance + flexibility + safety Challenge: Finding generally useful abstractions Lots of work remains http://www.cs.cornell.edu/talc 1 May 1999 www.cs.cornell.edu/talc