GWP-ASan: Sampling-Based Detection of Memory-Safety Bugs in Production (2311.09394v2)
Abstract: Despite the recent advances in pre-production bug detection, heap-use-after-free and heap-buffer-overflow bugs remain the primary problem for security, reliability, and developer productivity for applications written in C or C++, across all major software ecosystems. Memory-safe languages solve this problem when they are used, but the existing code bases consisting of billions of lines of C and C++ continue to grow, and we need additional bug detection mechanisms. This paper describes a family of tools that detect these two classes of memory-safety bugs, while running in production, at near-zero overhead. These tools combine page-granular guarded allocation and low-rate sampling. In other words, we added an "if" statement to a 36-year-old idea and made it work at scale. We describe the basic algorithm, several of its variants and implementations, and the results of multi-year deployments across mobile, desktop, and server applications.
- James P. Anderson “Computer security technology planning study”, 1972
- Hilarie Orman “The Morris worm: A fifteen-year perspective” In IEEE Security & Privacy 1.5 IEEE, 2003, pp. 35–43
- “Valgrind: a framework for heavyweight dynamic binary instrumentation” In PLDI ACM, 2007, pp. 89–100 DOI: 10.1145/1250734.1250746
- “AddressSanitizer: A Fast Address Sanity Checker” In USENIX USENIX Association, 2012, pp. 309–318 URL: https://www.usenix.org/conference/atc12/technical-sessions/presentation/serebryany
- “Memory Tagging and how it improves C/C++ memory safety” In CoRR abs/1802.09517, 2018 arXiv:1802.09517
- “M7: Oracle’s Next-Generation Sparc Processor” In IEEE Micro 35.2, 2015, pp. 36–45 DOI: 10.1109/MM.2015.35
- Kostya Serebryany “ARM Memory Tagging Extension and How It Improves C/C++ Memory Safety” In login Usenix Mag. 44.2, 2019 URL: https://www.usenix.org/publications/login/summer2019/serebryany
- Larry Smith “Shift-Left Testing” In Dr. Dobb’s J. 26.9 USA: CMP Media, Inc., 2001
- “SoK: Eternal War in Memory” In 2013 IEEE Symposium on Security and Privacy, SP 2013, Berkeley, CA, USA, May 19-22, 2013 IEEE Computer Society, 2013 DOI: 10.1109/SP.2013.13
- Alex Gaynor “What science can tell us about C and C++’s security”, 2020 URL: https://alexgaynor.net/2020/may/27/science-on-memory-unsafety-and-security/
- Bruce Perens “efence: Electric Fence Malloc Debugger”, 2003 URL: https://web.archive.org/web/20100829220331/http://perens.com/FreeSoftware/ElectricFence/
- Microsoft Corporation “GFlags and PageHeap”, 2022 URL: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags-and-pageheap
- “Google-Wide Profiling: A Continuous Profiling Infrastructure for Data Centers” In IEEE Micro 30.4, 2010, pp. 65–79 DOI: 10.1109/MM.2010.68
- Brian Randell “On Failures and Faults” In FME 2003: Formal Methods, International Symposium of Formal Methods Europe, Pisa, Italy, September 8-14, 2003, Proceedings 2805, Lecture Notes in Computer Science Springer, 2003 DOI: 10.1007/978-3-540-45236-2\_3
- John L. Hennessy and David A. Patterson “Computer Architecture - A Quantitative Approach, 5th Edition” Morgan Kaufmann, 2012
- The TCMalloc Authors “TCMalloc: Thread-Caching Malloc”, 2023 URL: https://github.com/google/tcmalloc
- Adrian Taylor, Bartek Nowierski and Kentaro Hara “Use-after-freedom: MiraclePtr”, 2022 URL: https://security.googleblog.com/2022/09/use-after-freedom-miracleptr.html
- The LLVM Authors “compiler-rt runtime libraries”, 2023 URL: https://compiler-rt.llvm.org/
- Chris Lattner and Vikram S. Adve “LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation” In CGO IEEE Computer Society, 2004, pp. 75–88 DOI: 10.1109/CGO.2004.1281665
- Jonathan Corbet “The SLUB allocator” In Linux Weekly News (LWN), 2007 URL: https://lwn.net/Articles/229984/
- The Linux Kernel Authors “Static Keys”, 2023 URL: https://docs.kernel.org/staging/static-keys.html
- Gray Watson “Debug Malloc Library”, 2020 URL: https://dmalloc.com/docs/dmalloc.pdf
- “Bug isolation via remote program sampling” In PLDI ACM, 2003 DOI: 10.1145/781131.781148
- George C. Necula, Scott McPeak and Westley Weimer “CCured: type-safe retrofitting of legacy code” In POPL ACM, 2002 DOI: 10.1145/503272.503286
- “Statistical debugging using compound boolean predicates” In ISSTA ACM, 2007 DOI: 10.1145/1273463.1273467
- Matthias Hauswirth and Trishul M. Chilimbi “Low-overhead memory leak detection using adaptive statistical profiling” In ASPLOS ACM, 2004 DOI: 10.1145/1024393.1024412
- “GWP-TSan: Zero-Cost Detection of Data Races in Production”, 2020 URL: https://llvm.org/devmtg/2020-09/slides/Morehouse-GWP-Tsan.pdf
- The Linux Kernel Authors “Memory Protection Keys”, 2023 URL: https://www.kernel.org/doc/html/latest/core-api/protection-keys.html
- “Lightweight UaF Detector”, 2022 URL: https://docs.google.com/document/d/1xfGa_IMtFZiQ3beOmkncEafODwn4U90ZyL4NfPaAtDY/edit?resourcekey=0-89BZl1SVILB6ylOHula0IA