Practical Byte-Granular Memory Blacklisting Using Califorms Hiroshi Sasaki Miguel A

Practical Byte-Granular Memory Blacklisting Using Califorms Hiroshi Sasaki Miguel A

Practical Byte-Granular Memory Blacklisting using Califorms Hiroshi Sasaki Miguel A. Arroyo M. Tarek Ibn Ziad Columbia University Columbia University Columbia University [email protected] [email protected] [email protected] Koustubha Bhaty Kanad Sinha Simha Sethumadhavan Vrije Universiteit Amsterdam Columbia University Columbia University [email protected] [email protected] [email protected] Abstract memory safety violations [1]. In response to the severity of Recent rapid strides in memory safety tools and hardware this threat, improvements in software checking tools, such as have improved software quality and security. While coarse- AddressSanitizer [2], and advances in the form of commercial grained memory safety has improved, achieving memory hardware support for memory safety such as Oracle’s ADI [3] safety at the granularity of individual objects remains a chal- and Intel’s MPX [4] have enabled programmers to detect and lenge due to high performance overheads which can be be- fix memory safety violations before deploying software. tween ∼1.7x−2.2x. In this paper, we present a novel idea Current software and hardware-supported solutions excel called Califorms, and associated program observations, to at providing coarse-grained memory safety, i.e., detecting obtain a low overhead security solution for practical, byte- memory access beyond arrays and malloc’d regions (struct granular memory safety. and class instances). However, they are not suitable for fine- The idea we build on is called memory blacklisting, which grained memory safety (i.e., detecting overflows within ob- prohibits a program from accessing certain memory regions jects, such as fields within a struct, or members within a based on program semantics. State of the art hardware- class) due to the high performance overheads and/or need supported memory blacklisting while much faster than soft- for making intrusive changes to the source code [5]. For ware blacklisting creates memory fragmentation (of the order instance, a recent work that aims to provide intra-object of few bytes) for each use of the blacklisted location. In this overflow protection functionality incurs a 2.2x performance paper, we observe that metadata used for blacklisting can be overhead [6]. These overheads are problematic because they stored in dead spaces in a program’s data memory and that not only reduce the number of pre-deployment tests that this metadata can be integrated into microarchitecture by can be performed, but also impede post-deployment con- changing the cache line format. Using these observations, tinuous monitoring, which researchers have pointed out is Califorms based system proposed in this paper reduces the necessary for detecting benign and malicious memory safety performance overheads of memory safety to ∼1.02x−1.16x violations [7]. Thus, a low overhead memory safety solution while providing byte-granular protection and maintaining that can enable continuous monitoring and provide complete very low hardware overheads. program safety has been elusive. The low overhead offered by Califorms enables always The source of overheads stem from how current designs on, memory safety for small and large objects alike, and store and use metadata necessary for enforcing memory the fundamental idea of storing metadata in empty spaces, safety. In Intel MPX [4], Hardbound [8], CHERI [9, 10], and and microarchitecture can be used for other security and PUMP [11], the metadata is stored for each pointer, and each arXiv:1906.01838v3 [cs.CR] 10 Jun 2019 performance applications. data or code memory access through a pointer performs checks using the metadata. Since C/C++ memory accesses 1 Introduction tend to be highly pointer based, the performance and energy overheads of accessing metadata can be significant in such With recent interest in microarchitecture side channels, it systems. Furthermore, the management of metadata espe- is important not to lose sight of more traditional software cially if it is stored in a disjoint manner from the pointer can security threats. Security is a full-system property where also create significant engineering complexity in terms of both software and hardware have to be secure for a system performance and usability. This was evidenced by the fact to be secure. Historically, program memory safety violations that compilers like LLVM and GCC dropped support for Intel have provided a significant opportunity for exploitation: for MPX in their mainline after an initial push to integrate into instance, a recent report from Microsoft revealed that the the toolchain [4]. root cause of more than half of all exploits were software Our approach for reducing overheads is two-fold. First, yPart of this work was carried out while the author was a visiting student instead of checking access bounds for each pointer access, we at Columbia University. 1 H. Sasaki, M. Arroyo, M. Tarek Ibn Ziad, K. Bhat, K. Sinha, and S. Sethumadhavan blacklist all memory locations that should never be accessed. L2 In theory, this is a strictly weaker form of security than Core L1D whitelisting but we argue that in practice, blacklisting can Dead byte be more practical because of its ease of deployment and low overheads. Informally, deployments apply whitelisting Natural Califorms techniques partially to reduce overheads and be backward A B C D E Header A B C D E compatible which reduces their security, while blacklisting Natural Natural techniques can be applied more broadly due to their low 1 3 7 4 8 6 7 5 1 3 7 4 8 6 7 5 overheads. Additionally, blacklisting techniques complement defenses in existing systems better since they do not require Figure 1. Califorms offers memory safety by detecting ac- intrusive changes. cesses to dead bytes in memory. Dead bytes are not stored be- Our second optimization is the novel metadata storage yond the L1 data cache and identified using a special header scheme. We observe that by using dead memory spaces in the in the L2 cache (and beyond) resulting in very low overhead. program, we can store metadata needed for memory safety The conversion between these formats happens when lines for free for nearly half of the program objects. These dead are filled or spilled between the L1 and L2 caches. Theab- spaces occur because of language alignment requirements sence of dead bytes results in the cache lines stored in the and are inserted by the compiler. When we cannot find a same natural format across memory system. naturally occurring dead space, we manually insert a dead space. The overhead due to this dead space is smaller than are substantially lower compared to the state-of-the-art soft- traditional methods for storing metadata because of how we ware or hardware supported schemes (viz., 2.2x performance represent the metadata: our metadata is smaller (one byte) and 1.1x memory overheads for EffectiveSan [6], and 1.7x as opposed to multiple bytes with traditional whitelisting or performance and 2.1x memory overheads for Intel MPX [4]). blacklisting memory safety techniques. A natural question is how the dead (more commonly re- ferred to as padding) bytes can be distinguished from normal 2 Motivation bytes in memory. A straightforward scheme results in one One of the key ways in which we mitigate the overheads bit of additional storage per byte to identify if a byte is a for fine-grained memory safety is by opportunistically har- dead byte; this scheme results in a space overhead of 12.5%. vesting padding bytes in programs to store metadata. So how We reduce this overhead to one bit per 64B cache line (0.2% often do these occur in programs? Before we answer that overhead) without any loss of precision by only reformatting question let us concretely understand padding bytes with how data is stored in cache lines. Our technique, Califorms, an example. Consider the struct A defined in Listing 1(a). uses one bit of additional storage to identify if the cache line Let us say the compiler inserts a three-byte padding in be- associated with the memory contains any dead bytes. For cal- tween char c and int i as in Listing 1(b) because of the iformed cache lines, i.e., lines which contain dead bytes, the C language requirement that integers should be padded to actual data is stored following the “header”, which indicates their natural size (which we assume to be four bytes here). the location of dead bytes, as shown in Figure 1. These types of paddings are not limited to C/C++ but also With this support, it is easy to describe how a Califorms many other languages and their runtime implementations. based system for memory safety works. The dead bytes, To obtain a quantitative estimate on the amount of paddings, either naturally harvested or manually inserted, are used to we developed a compiler pass to statically collect the padding indicate memory regions that should never be accessed by size information. Figure 3 presents the histogram of struct a program (i.e., blacklisting). If an attacker accesses these densities for SPEC CPU2006 C and C++ benchmarks and regions, we detect this rogue access without any additional the V8 JavaScript engine. Struct density is defined as the metadata accesses as our metadata resides inline. sum of the size of each field divided by the total size of the Our experimental results on the SPEC CPU2006 bench- struct including the padding bytes (i.e., the smaller or sparse mark suite indicate that the overheads of Califorms are quite the struct density the more padding bytes the struct has). low: software overheads range from 2 to 14% slowdown The results reveal that 45:7% and 41:0% of structs within (or alternatively, 1.02x to 1.16x performance overhead) de- SPEC and V8, respectively, have at least one byte of padding.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us