Systems and Internet Infrastructure Security (SIIS) Laboratory Page
Systems and Internet Infrastructure Security
Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA
1
CCured: Type-safe Retrofitting of Legacy Code By Necula, McPeak, - - PowerPoint PPT Presentation
Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA CCured: Type-safe Retrofitting of Legacy Code By Necula,
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA
1
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
2
This generally required writing assembly code
They realized they needed something fast and portable.
The rest is history
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
3
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
4
Linux, Unix, Solaris, Windows
Billions of dollars of software Linux kernel is estimated to be worth $700 million in programmer productivity Millions of lines of code. Linux kernel has more than 10 million lines of code
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
5
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
6
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
7
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
8
Annotated C Program
CCured Translator
Instrumented C Program
Compile & Execute Halt: Memory Safety Violation Success
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
9
Un-annotated C Program
CCured Translator
Instrumented C Program
Compile & Execute Halt: Memory Safety Violation Success
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
10
int* p = (int*)malloc( sizeof(int) ); // // What if malloc() fails? if( p == NULL ) return -1; *p = 3; printf( "p is %d\n", *p );
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
11
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
12
int i; int* array = (int*)malloc( 5 * sizeof(int) ); if( array == NULL ) return -1; for( i = 0; i < 5; i++ ) array[i] = i; printf( "array[2] is %d\n", *(array + 2) ); // What if we accidently // step out of bounds?
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
13
!= NULL:
to make sure arithmetic expressions do not move outside an expected bound.
statically with CCured.
‘end’) is stored as metadata alongside the pointer. This creates “fat pointers.”
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
14
int* testValue = (int*)malloc( sizeof(int) ); *testValue = 1; char* lsb = (char*)testValue; // On the rhs, we cast an int* to a char* // The statically declared type of the lhs // is misleading, due to this cast. if( *lsb == 1 ) printf("This is a little-endian system\n"); else printf("This is a big-endian system\n");
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
15
heterogeneous type is considered WILD.
WILD pointer (either through assignment or deference) must be inferred as WILD.
run-time with CCured.
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
16
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
17
a = SEQ Pointer arithmetic on Line 8 p = SAFE Simple dereference on line 9 e = WILD Line 5 says it declared as type (int*) but it is cast in Line 11 as (int**)
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
18
C Program CCured Translator
Instrumented C Program
Compile & Execute Halt: Memory Safety Violation Success
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
19
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
20
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
21
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
22
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
23
E.g., sizeof() will no longer works as expected on pointers
free()’s are ignored
Systems and Internet Infrastructure Security (SIIS) Laboratory Page
24