skip to main content
10.1145/1542476.1542505acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Implementation of the memory-safe full ANSI-C compiler

Authors Info & Claims
Published:15 June 2009Publication History

ABSTRACT

This paper describes a completely memory-safe compiler for C language programs that is fully compatible with the ANSI C specification.

Programs written in C often suffer from nasty errors due to dangling pointers and buffer overflow. Such errors in Internet server programs are often exploited by malicious attackers to crack an entire system. The origin of these errors is usually corruption of in-memory data structures caused by out-of-bound array accesses. Usual C compilers do not provide any protection against such out-of-bound access, although many other languages such as Java and ML do provide such protection. There have been several proposals for preventing such memory corruption from various aspects: runtime buffer overrun detectors, designs for new C-like languages, and compilers for (subsets of) the C language. However, as far as we know, none of them have achieved full memory protection and full compatibility with the C language specification at the same time.

We propose the most powerful solution to this problem ever presented. We have developed Fail-Safe C, a memory-safe implementation of the full ANSI C language. It detects and disallows all unsafe operations, yet conforms to the full ANSI C standard (including casts and unions). This paper introduces several techniques--both compile-time and runtime--to reduce the overhead of runtime checks, while still maintaining 100% memory safety. This compiler lets programmers easily make their programs safe without heavy rewriting or porting of their code. It also supports many of the "dirty tricks" commonly used in many existing C programs, which do not strictly conform to the standard specification. In this paper, we demonstrate several real-world server programs that can be processed by our compiler and present technical details and benchmark results for it.

References

  1. American National Standard Institute. American national standard for information systems -- programming language -- C. ANSI X3.159-1989.Google ScholarGoogle Scholar
  2. Todd M. Austin, Scott E. Breach, and Gurindar S. Sohi. Efficient detection of all pointer and array access errors. In Proc. '94 Conference on Programming Language Design and Implementation (PLDI), pages 290---301, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Hans Boehm. A garbage collector for C and C++. http: //www.hpl.hp.com/personal/Hans Boehm/gc/.Google ScholarGoogle Scholar
  4. Hans Boehm and Mark Weiser. Garbage collection in an uncooperative environment. Software: Practice & Experience, pages 807--820, September 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Jeremy Condit, Matthew Harren, Scott McPeak, George C. Necula, and Westley Weimer. CCured in the real workd. In ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 232--244, June 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Crispan Cowan, Calton Pu, Dave Maier, Jonathan Walpole, Peat Bakke, Steve Beattie, Aaron Grier, Perry Wagle, Qian Zhang, and Heather Hinton. StackGuard: Automatic adaptive detection and prevention of buffer-overflow attacks. In Proc. 7th USENIX Security Conference, pages 63--78, San Antonio, Texas, January 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Hiroaki Etoh and Kunikazu Yoda. Propolice: Improved stacksmashing attack detection. IPSJ SIG Notes, 2001(75):181--188, 2001.Google ScholarGoogle Scholar
  8. Jun Furuse. VITC: Safe C code compilation against attacks. In 4th Workshop on Dependable Software, 2006. In Japanese.Google ScholarGoogle Scholar
  9. Dan Grossman, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and James Cheney. Region-based memory management in Cyclone. In Proc. ACM Conference on Programming Language Design and Implementation (PLDI), pages 282--293, June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. International Organization for Standards and International Electrotechnical Commission. Programming languages -- C. ISO/IEC Standard ISO/IEC 9899:1990.Google ScholarGoogle Scholar
  11. Trevor Jim, Greg Morrisett, Dan Grossman, Michael Hicks, James Cheney, and YanlingWang. Cyclone: A safe dialect of C. In USENIX Annual Technical Conference, June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Richard W. M. Jones and Paul H. J. Kelly. Backwards-compatible bounds checking for arrays and pointers in C programs. In Automated and Algorithmic Debugging, pages 13--26, 1997.Google ScholarGoogle Scholar
  13. Yuhki Kamijima and Eijiro Sumii. Safe implementation of C pointer arithmetics by translation to Java. JSSST, 26(1):139--154, 2009. In japanese.Google ScholarGoogle Scholar
  14. Brian W. Kernighan and Dennis M. Ritchie. The Programming Language C. Prentice Hall, second edition, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Alexey Loginov, Suan Hsi Yong, Susan Horwitz, and Thomas Reps. Debugging via run--time type checking. Lecture Notes in Computer Science, 2029:217--, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Type-safe retrofitting of legacy code. In Proc. The 29th Annual ACM SIGPLAN--SIGACT Symposium on Principles of Programming Languages (POPL2002), pages 128--139, January 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Yutaka Oiwa. Fail-Safe C webpage. https://staff.aist.go.jp/y.oiwa/FailSafeC/index--en.html.Google ScholarGoogle Scholar
  18. Yutaka Oiwa. An extension to Fail-Safe C to support object-oriented languages. In Symposium on Programming and Programming Languages, March 2005.Google ScholarGoogle Scholar
  19. Yutaka Oiwa. Implementation of a Fail-Safe ANSI C Compiler. PhD thesis, University of Tokyo, 2005.Google ScholarGoogle Scholar
  20. Yutaka Oiwa. Type-safe linking of C programs. In Symposium on Programming and Programming Languages, March 2007.Google ScholarGoogle Scholar
  21. Gray Watson. Dmalloc -- debug malloc library. http://www.dmalloc.com/.Google ScholarGoogle Scholar
  22. George Necula, Scott McPeak, and Westley Weimer. CCured:Google ScholarGoogle Scholar

Index Terms

  1. Implementation of the memory-safe full ANSI-C compiler

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      PLDI '09: Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation
      June 2009
      492 pages
      ISBN:9781605583921
      DOI:10.1145/1542476
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 44, Issue 6
        PLDI '09
        June 2009
        478 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1543135
        Issue’s Table of Contents

      Copyright © 2009 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 15 June 2009

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate406of2,067submissions,20%

      Upcoming Conference

      PLDI '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader