IEEE Access (Jan 2024)

Enhancing a Lock-and-Key Scheme With MTE to Mitigate Use-After-Frees

  • Inyoung Bang,
  • Martin Kayondo,
  • Junseung You,
  • Donghyun Kwon,
  • Yeongpil Cho,
  • Yunheung Paek

DOI
https://doi.org/10.1109/ACCESS.2023.3343777
Journal volume & issue
Vol. 12
pp. 5462 – 5476

Abstract

Read online

Preventing Use-After-Free (UAF) bugs is crucial to ensure temporal memory safety. Against UAF attacks, much research has adopted a well-known approach, lock-and-key, in which unique, disposable locks and keys are first assigned respectively to objects and pointers, and then on every memory access, checked for a match. Attention has been drawn again to this approach by recent work that capitalizes on a vast abundance of virtual address (VA) space in the lock assignment, thus being able to prevent UAFs in stripped binary. However, as this VA-based lock-and-key scheme tends to rapidly consume virtual space, it is likely to suffer from high performance overhead. In this paper, we propose a new scheme, called the VA tagging, whose goal is to tackle this performance problem with the support of the Memory Tagging Architecture (MTA) introduced in several commodity processors. In our scheme, the original VA-based locks are augmented with tags of MTA. As a VA-based lock can be assigned to multiple objects with different tags, the same VA is reused for many objects without compromising temporal safety. We have observed in our experiments that this tagging scheme lowers the VA consumption rate drastically by one order of magnitude. We implement a light-weight memory allocator, Vatalloc, by modifying existing allocators, dlmalloc and jemalloc, to employ the VA tagging scheme for efficient prevention of UAFs. Our evaluation shows that Vatalloc with allocator modifications only incurs 1.70% (on dlmalloc) and 3.05% (on jemalloc) of runtime overhead without considering performance degradation of MTE. As a result of simulating the tagging architecture assuming the worst-case, postulating MTE precise trapping mode incurs performance overhead of 30.9% based on dlmalloc, and 25.5% based on jemalloc. If imprecise mode is assumed, the slowdown is measured 16.9% for dlmalloc and 12.0% for jemalloc respectively. Vatalloc only incurs 19.0% and 3.0% memory overhead for dlmalloc and jemalloc respectively.

Keywords