Certified self-modifying code

被引:18
作者
Cai, Hongxu [1 ]
Shao, Zhong [2 ]
Vaynberg, Alexander [2 ]
机构
[1] Tsinghua Univ, Dept Comp Sci & Technol, Beijing 100084, Peoples R China
[2] Yale Univ, Dept Comp Sci, New Haven, CT 06520 USA
关键词
languages; verification; self-modifying code; runtime code manipulation; assembly code verification; modular verification; Hoare logic;
D O I
10.1145/1273442.1250743
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Self-modifying code (SMC), in this paper, broadly refers to any program that loads, generates, or mutates code at runtime. It is widely used in many of the world's critical software systems to support runtime code generation and optimization, dynamic loading and linking, OS boot loader, just-in-time compilation, binary translation, or dynamic code encryption and obfuscation. Unfortunately, SMC is also extremely difficult to reason about: existing formal veri. cation techniques-including Hoare logic and type system consistently assume that program code stored in memory is fixed and immutable; this severely limits their applicability and power. This paper presents a simple but novel Hoare-logic-like framework that supports modular veri. cation of general von-Neumann machine code with runtime code manipulation. By dropping the assumption that code memory is fixed and immutable, we are forced to apply local reasoning and separation logic at the very beginning, and treat program code uniformly as regular data structure. We address the interaction between separation and code memory and show how to establish the frame rules for local reasoning even in the presence of SMC. Our framework is realistic, but designed to be highly generic, so that it can support assembly code under all modern CPUs (including both x86 and MIPS). Our system is expressive and fully mechanized. We prove its soundness in the Coq proof assistant and demonstrate its power by certifying a series of realistic examples and applications-all of which can directly run on the SPIM simulator or any stock x86 hardware.
引用
收藏
页码:66 / 77
页数:12
相关论文
共 31 条
[1]  
[Anonymous], POPL 2001
[2]  
[Anonymous], 2005, ADV TOPICS TYPES PRO
[3]  
Appel AndrewW., 2000, P 27 ACM SIGPLAN SIG, P243
[4]   Foundational proof-carrying code [J].
Appel, AW .
16TH ANNUAL IEEE SYMPOSIUM ON LOGIC IN COMPUTER SCIENCE, PROCEEDINGS, 2001, :247-256
[5]  
AUCSMITH D, 1996, P 1 INT WORKSH INF H, P317
[6]  
BALA V, 2000, P ACM SIGPLAN C PROG, P1, DOI DOI 10.1145/349299.349303
[7]  
Cai H, 2007, YALEUDCSTR1379
[8]  
*COQ DEV TEAM INRI, 2004, COQ PROOF ASS REF MA
[9]  
CRARY K, 2003, POPL 03, P198
[10]  
DEBRAY S, 2002, P ACM SIGPLAN 2002 C, P95