HardBound: Architectural Support for Spatial Safety of the C Programming Language Joe Devietti *, Colin Blundell, Milo Martin, Steve Zdancewic * University.

Slides:



Advertisements
Similar presentations
Multicore Acceleration of Priority-Based Schedulers for Concurrency Bug Detection Santosh Nagarakatte, Sebastian Burckhardt, Milo Martin, Madan Musuvathi.
Advertisements

Win8 on Intel Programming Course Win8 for developers, in detail Cédric Andreolli Intel.
Win8 on Intel Programming Course Desktop : Introduction Cédric Andreolli Intel Software.
Algorithms and data structures Protected by
Multicore Programming Skip list Tutorial 10 CS Spring 2010.
Win8 on Intel Programming Course Desktop : WPF Cédric Andreolli Intel Software
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
Intel Do-It-Yourself Challenge node.js
The State Transition Diagram
8. Static Single Assignment Form Marcus Denker. © Marcus Denker SSA Roadmap  Static Single Assignment Form (SSA)  Converting to SSA Form  Examples.
Algorithms and data structures
7. Optimization Prof. O. Nierstrasz Lecture notes by Marcus Denker.
12. Common Errors, a few Puzzles. © O. Nierstrasz P2 — Common Errors, a few Puzzles 12.2 Common Errors, a few Puzzles Sources  Cay Horstmann, Computing.
Win8 on Intel Programming Course Win8 and Intel Paul Guermonprez Intel Software
Secure Low-Level Programming via Hardware-Assisted Memory-Safe C Prof. Milo Martin Santosh Nagarakatte, Joe Devietti, Jianzhou Zhao, Colin Blundell Prof.
Object-Oriented Reengineering Patterns and Techniques Prof. O. Nierstrasz Prof. S. Ducasse T.
12. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Roadmap  Summary: —Trends in programming paradigms  Research:...
Shared Counters and Parallelism Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
ESE Einführung in Software Engineering N. XXX Prof. O. Nierstrasz Fall Semester 2009.
© Oscar Nierstrasz ST — Smalltalk Basics 2.1 Change sets  Make sure your changes are logged to a new change set.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
Metamodeling Seminar X. CHAPTER Prof. O. Nierstrasz Spring Semester 2008.
© Oscar Nierstrasz ST — Smalltalk Basics 2.1 Change sets  Make sure your changes are logged to a new change set.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
N. XXX Prof. O. Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
CCured in the Real World Jeremy ConditMatthew Harren Scott McPeakGeorge Necula Westley Weimer OSQ Retreat May 14, 2003.
HARDBOUND: ARCHITECURAL SUPPORT FOR SPATIAL SAFETY OF THE C PROGRAMMING LANGUAGE Kyle Yan Yu Xing 2014/10/15.
Internet of Things with Intel Edison Led sensor lab
© S. Demeyer, S. Ducasse, O. Nierstrasz Chapter.1 MakeMoney Corp. C*O of MakeMoney Corp. Our Vision  We invest in software  We do not know software 
OORPT Object-Oriented Reengineering Patterns and Techniques X. CHAPTER Prof. O. Nierstrasz.
CP — Concurrent Programming X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
May 22, 2002OSQ Retreat 1 CCured: Taming C Pointers George Necula Scott McPeak Wes Weimer
12. eToys. © O. Nierstrasz PS — eToys 12.2 Denotational Semantics Overview:  … References:  …
SWOT Analysis Strengths Weaknesses SWOT Opportunities Threats.
Collecting Images & Clippings Chapter 2.3 in Sketching User Experiences: The Workbook.
Win8 on Intel Programming Course The challenge Paul Guermonprez Intel Software
Computational Sprinting on a Hardware/Software Testbed Arun Raghavan *, Laurel Emurian *, Lei Shao #, Marios Papaefthymiou +, Kevin P. Pipe +#, Thomas.
Multicore Programming
Internet of Things with Intel Edison Compiling and running Pierre Collet Intel Software.
© Copyright Showeet.com I NSERT YOUR TITLE HERE. © Copyright Showeet.com Insert Your Title Here 2 Master text styles –Second level Third level –Fourth.
The Animated Sequence Chapter 5.1 in Sketching User Experiences: The Workbook.
Numerical Methods Multi Dimensional Direct Search Methods - Theory
Numerical Methods Continuous Fourier Series Part: Continuous Fourier Series
11/17/ Introduction to Partial Differential Equations Transforming Numerical.
Sketching Vocabulary Chapter 3.4 in Sketching User Experiences: The Workbook Drawing objects, people, and their activities.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
Win8 on Intel Programming Course Paul Guermonprez Intel Software
State of the Ward in 2007 Version 1.0 A Fifth Sunday Lesson Given in the Sterling Park Ward, Ashburn, VA Stake by D. Calvin Andrus, Bishop
Design of Everyday Things Part 2: Useful Designs? Lecture /slide deck produced by Saul Greenberg, University of Calgary, Canada Images from:
On Welfare Principles 5th Sunday Lesson Sterling Park Ward Ashburn, Virginia Stake Taught by: D. Calvin Andrus, Bishop and the Welfare Committee 29 March.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
2/13/ Elliptic Partial Differential Equations - Introduction Transforming.
Images of pesticides By: Leslie London, University of Cape Town This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5.
The Relative Power of Synchronization Operations Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Numerical Methods Multidimensional Gradient Methods in Optimization- Example
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
PHPBelgium – Belgian PHP community PHPBelgium event MVC = Make Venerated Code? Patrick Allaert.
1 Licence This presentation document is one used by Ryan Cartwright of Equitas IT Solutions [1] and is Copyright © 2008 Ryan P. Cartwright / Equitas IT.
PHPBelgium – Belgian PHP community PHPBelgium event PHP & the MVC Pattern Patrick Allaert
Sketching Vocabulary Chapter 3.4 in Sketching User Experiences: The Workbook Drawing objects, people, and their activities.
Agenda Video pre-presentations Digital sketches & photo traces
malloc(): Dynamic Memory Management
Byzantine-Resilient Colorless Computaton
Pre and post workshop assessments
FOTW Worksheet Slides Christopher Penn, Financial Aid Podcast Student Loan Network.
Code-Pointer Integrity
Numerical Methods Newton’s Method for One -Dimensional Optimization - Example
CETS: Compiler-Enforced Temporal Safety for C
Electronic resources in Rongo University college
Presentation transcript:

HardBound: Architectural Support for Spatial Safety of the C Programming Language Joe Devietti *, Colin Blundell, Milo Martin, Steve Zdancewic * University of Washington, University of Pennsylvania {blundell, milom,

This work licensed under the Creative Commons Attribution-Share Alike 3.0 United States License You are free: to Share to copy, distribute, display, and perform the work to Remix to make derivative works Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to: Any of the above conditions can be waived if you get permission from the copyright holder. Apart from the remix rights granted under this license, nothing in this license impairs or restricts the author's moral rights. [ 2 ] HardBound – Joe Devietti – ASPLOS 2008

Who cares about spatial safety, anyway? [ 3 ] HardBound – Joe Devietti – ASPLOS 2008 January 14 February 12 February 8 January 16

HardBound: Spatial Safety for C Bounded pointer primitive in hardware A new hardware/software contract for pointers Software finds where pointers are created Hardware checks and propagates pointers Inspired by software-only fat pointer proposals Pointers become (pointer, base, bound) triples +Can provide complete spatial safety Changes memory layout Hardware support enables: Unchanged memory layout high compatibility Efficient fat pointer encodings low overheads (5%) [ 4 ] HardBound – Joe Devietti – ASPLOS 2008

memory Spatial Violation Example struct BankAccount { char acctID[3]; int balance; } b;... b.balance = 0; char* id = b.acctID; inputID(id);... void inputID(char* p) { while (*p = readchar()) p++; } [ 5 ] HardBound – Joe Devietti – ASPLOS 2008 bal id acctID x p p

Preventing Spatial Violations [ 6 ] HardBound – Joe Devietti – ASPLOS 2008 write perfect code treat the symptoms address space randomization non-executable stack/heap protect return addresses all incomplete add bounds checking to C use a safe language what about existing code?

Software-Only Bounds Checking for C approach can handle sub-objects? compatibility?examples object lookup nohigh Jones & Kelly [1997] CRED [Ruwase & Lam, 2004] JK/RL/DA [Dhurjati & Adve, 2006] fat pointer yeslow SafeC [Austin et al, 1994] Cyclone [Jim et al, 2002] CCured [Necula et al, 2005] [ 7 ] HardBound – Joe Devietti – ASPLOS 2008

Code Example with Fat Pointers struct BankAccount { char acctID[3]; int balance; } b;... b.balance = 0; char* id = b.acctID; inputID(id);... void inputID(char* p) { while (*p = readchar()) p++; } [ 8 ] HardBound – Joe Devietti – ASPLOS 2008 acctID bound id base pointer bal 0 p p pointer base bound

standard C layout fat pointer layout struct { int* ptr; int i; } s; ptr i i base bound i ptr CCured +Uses fat pointers only where needed determined by whole-program type inference significantly reduces overhead Curing a program requires programmer help Interfacing with non-cured libraries C nastiness: arbitrary casts, unions, … CCured team: 1% of source code lines changed Spec95, Olden, Ptrdist [ 9 ] HardBound – Joe Devietti – ASPLOS 2008 Curing a program is a non-trivial task

HardBound: A New Hope Bounded pointer hardware primitive implemented via shadow memory and registers Compiler identifies where pointers are created examples: malloc, &variable (intraprocedural analysis) using setbound instruction Hardware checks and propagates the pointers +Fat pointer representation hidden by hardware +compatible (memory layout unchanged) +enables optimized metadata encodings [ 10 ] HardBound – Joe Devietti – ASPLOS 2008

Rest of Talk How do we make HardBound work? pointer propagation and checking memory layout How do we make HardBound fast? compressing non-pointers compressing pointers [ 11 ] HardBound – Joe Devietti – ASPLOS 2008

Metadata Propagation and Checking All registers and memory have metadata Example operations: a dd R1 < R2 + imm R1.value < R2.value + imm R1.base < R2.base R1.bound < R2.bound l oad R1 < Memory[R2] assert(R2.base <= R2.value < R2.bound) R1.value < Memory[R2.value].value R1.base < Memory[R2.value].base R1.bound < Memory[R2.value].bound [ 12 ] HardBound – Joe Devietti – ASPLOS 2008 propagation bounds check propagation insn

struct BankAccount { char acctID[3]; int balance; } b;... b.balance = 0; char* id; id = inputID(id);... void inputID(char* p) { while (*p = readchar()) p++; } The HardBound Hardware/Software Approach [ 13 ] HardBound – Joe Devietti – ASPLOS 2008 memory bal id acctID base bound pointer setbound(b.acctID,3); b.acctID; 0 p p base bound pointer propagation where?

HardBound Memory Layout [ 14 ] HardBound – Joe Devietti – ASPLOS 2008 Virtual Memory struct { int* ptr; int i; } s; ptr i i boundbase metadata shadow space regular space (layout unchanged) enables compatibility… …how do we make it fast?

Eliminating Metadata for Non-pointers Most data are not pointers add 1-bit tag to act as a filter prevents an expensive base/bound lookup lives in virtual memory 1 bit per word (3% overhead) [ 15 ] HardBound – Joe Devietti – ASPLOS 2008 non-pointer 0 0 pointer base bound 1 1 tag

Compressing In-Memory Metadata 1.Many pointers point to the beginning of an object 2.Many pointers point to small objects [ 16 ] HardBound – Joe Devietti – ASPLOS 2008 pointer: 1000 base: 1000 bound: tag:1 bound: 1003 used opportunistically on stores External encoding: fold size into tag base: size pointer: 1000

Most programs dont use much of virtual memory pointers contain more bits than are really needed base: 1000 Compressing Metadata for Pointers [ 17 ] HardBound – Joe Devietti – ASPLOS 2008 base: 1000 bound: 1003 tag: 1 bound: 1003 Internal encoding: hide offset in pointer + + cmprsd? size pointer:

HardBound Metadata Lookup [ 18 ] HardBound – Joe Devietti – ASPLOS 2008 Processor Core L2$ d$ i$ tag$ TLB Memory

Experiments Experimental methodology Source-to-source compiler written in CIL FeS 2 x86 inorder single-cycle processor with Simics Tested correctness with a suite of 291 spatial violations [Kratkiewicz & Lippmann, 2005] 286 are compatible with our simulation environment no false positives, no false negatives [ 19 ] HardBound – Joe Devietti – ASPLOS 2008

Performance Experiments Olden pointer-intensive benchmark suite no source code modifications required for correctness we even found a bug in em3d we made two small performance-only modifications bh: manually inlined two functions reduce number of redundant setbound insns mst: manually inserted three setbound insns to tighten bounds for better compression [ 20 ] HardBound – Joe Devietti – ASPLOS 2008

Experimental Configurations encodingsize of tag spacetag cache encodes pointers up to external 4-bit4 bits8KB56 B internal 4-bit1 bit2KB56 B internal 11-bit1 bit2KB4 KB [ 21 ] HardBound – Joe Devietti – ASPLOS 2008

Normalized Runtime Results [ 22 ] HardBound – Joe Devietti – ASPLOS 2008 bhbisort em3dhealthmst perimpowertreeaddtsp avg 5% average overhead

Conclusions HardBound is a hardware/software approach that provides spatial safety for C Hardware-managed pointer metadata enables: high compatibility (doesnt change memory layout) low overhead (enables encoding tricks) Our experiments show that HardBound is: effective (no false positives, no false negatives) efficient (compressing metadata works) Future work further reduce overhead using CCureds static analysis temporal safety (dangling pointers) [ 23 ] HardBound – Joe Devietti – ASPLOS 2008