<<

Memory and Type Safety for Embedded Systems

Paul Soulier Depeng Li [email protected] [email protected] University of Hawaii, Manoa University of Hawaii, Manoa

Abstract tion. Multi-processor devices have become commonplace. Security vulnerabilities that originate from memory- With the proliferation of multiprocessor architectures, related programming errors are all too common in sys- the complexity of maintaining memory integrity also tems programs and embedded systems with numerous increases. Language-level support for concurrency of- such flaws being reported each year. Over the past sev- fers many advantages in providing memory-safe opera- eral decades, many application domains have enjoyed ad- tions. Software-based isolation (as found in the Singu- vances in programming languages that make these vari- larity project [2]) can confine memory access to within a ety of errors all but non-existant while the vast majority given process and ensure accesses outside of the process of embedded systems are still written in the program- employ proper IPC mechanisms. This isolation mecha- ming language [3, 1]. The reasons for the continued use nism is enforced through the language pro- of C are certainly numerous, but there is one aspect of viding the significant advantage over hardware MMUs the C languages that sets it apart from other languages: of detecting errors at rather than runtime. power of expression. This power of expression enables Furthermore, various platforms do not programmers to write powerful applications for even the contain hardware-based MMUs making this the only vi- most obscure and obtuse hardware platforms that would able option to provide any memory isolation. not be possible in other languages; but it comes at a cost. Aliasing in a software system occurs when a single The C language is neither type safe nor memory safe. object in memory is addressed by more than one refer- The goal of this research is to define a type system that ence. Aliasing has the potential to reduce the compre- can ultimately be used in an alternative language to C. hensibility of code that can, in turn, lead to unanticipated The type system must be type safe, memory safe, and re- modifications to data when objects are manipulated in duce unexpected state modifications due to pointer alias- unexpected ways. References are generally used to pass ing and concurrent execution while still maintaining the an object from one procedure or object to another such expressive power that is found in C. that it can be modified. Frequently, there is little need Type and memory safe systems are well understood to maintain multiple references to a single object. The with many existing languages implementing them. How- use of value and linear types can help mini- ever, embedded systems pose unique challenges to type mize the occurrence of aliased objects thus reducing the systems that are not addressed by most languages where negative potential issues that arise from aliased objects. the necessity to interact with hardware through memory- Linear types also have the potential to offer a efficient mapped register windows or through protocols necessi- message-based IPC mechanism. tates the ability to precisely define and manipulate data With the ability incorporate more computational structures. For example, to ensure out-of-bounds access power into smaller packages and wireless connectivity, is not permitted, arrays in many languages maintain the embedded systems are finding their way into many criti- number of elements contained within by adding to the cal applications such as insulin pumps, sensor networks, overall memory required by the array. A protocol that and industrial control devices. Given the potential con- utilizes an array defines only the space required by the sequences of security flaws in such devices the need for elements. The type system must provide mechanisms for new type systems and programming languages to prevent ensuring such data structures maintain memory-safe op- software flaws is a critical component to ensuring the se- erations without altering the in-memory data organiza- curity of future embedded software systems. References

[1] BREWER,E.A.,CONDIT,J.,MCCLOSKEY,B., AND ZHOU, F. Thirty years is long enough: Getting beyond c. In HotOS (2005).

[2] HUNT,G.C., AND LARUS, J. R. Singularity: rethinking the software stack. ACM SIGOPS Operating Systems Review 41, 2 (2007), 37–49.

[3] SHAPIRO, J. challenges in systems codes: why systems programmers still use c, and what to do about it. In Proceedings of the 3rd workshop on Programming languages and operating systems: linguistic support for modern operating sys- tems (2006), ACM, p. 9.

2