Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/3689490.3690400acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article
Open access

Performant Bounds Checking for 64-Bit WebAssembly

Published: 17 October 2024 Publication History

Abstract

WebAssembly is becoming increasingly popular for various use cases due to its high portability, strict and easily enforceable isolation, and its comparably low run-time overhead. For determinism and security, WebAssembly guarantees that accesses to unallocated memory inside the 32-bit address space produce a trap. Typically, runtimes implement this by reserving all addressable WebAssembly memory in the host virtual memory and relying on page faults for out-of-bounds accesses. To accommodate programs with higher memory requirements, several execution runtimes also implement a 64-bit address space. However, bounds checking solely relying on virtual memory protection cannot be easily extended for 64 bits. Thus, popular runtimes resort to traditional bounds checks in software, which are required frequently and, therefore, incur a substantial run-time overhead. In this paper, we explore different ways to lower the bounds checking overhead for 64-bit WebAssembly using virtual memory techniques provided by modern hardware. In particular, we implement and analyze approaches using a combination of software checks and virtual memory, using two-level guard pages, and using unprivileged memory protection mechanisms like x86-64 memory keys. Our results show that we can reduce the bounds checking overhead from more than 100% when using software bounds checks to only 12.7% using two-level guard pages.

References

[1]
[n. d.]. WebAssembly Core Specification. Technical Report. W3C. https://www.w3.org/TR/wasm-core-2/ https://webassembly.github.io/spec/core/_download/WebAssembly.pdf.
[2]
Apple Inc. 2024. JavaScriptCore. https://docs.webkit.org/Deep%20Dive/JSC/JavaScriptCore.html
[3]
Arm Limited. 2024. Armv8.5-A Memory Tagging Extension Whitepaper. Technical Report. Arm Limited. https://developer.arm.com/-/media/Arm%20Developer%20Community/PDF/Arm_Memory_Tagging_Extension_Whitepaper.pdf
[4]
James Bucek, Klaus-Dieter Lange, and Jóakim V. Kistowski. 2018. SPEC CPU2017: Next-Generation Compute Benchmark. In Companion of the 2018 ACM/SPEC International Conference on Performance Engineering. ACM, Berlin Germany, 41–42. isbn:978-1-4503-5629-9
[5]
Bytecode Alliance. 2023. WebAssembly Micro Runtime. https://bytecodealliance.github.io/wamr.dev/
[6]
Bytecode Alliance. 2024. Wasmtime. https://wasmtime.dev/
[7]
Tzi-cker Chiueh. 2008. Fast Bounds Checking Using Debug Register. In High Performance Embedded Architectures and Compilers, Per Stenström, Michel Dubois, Manolis Katevenis, Rajiv Gupta, and Theo Ungerer (Eds.). Vol. 4917. Springer Berlin Heidelberg, Berlin, Heidelberg, 99–113. isbn:978-3-540-77559-1 978-3-540-77560-7
[8]
Cloud Native Computing Foundation. 2024. WasmEdge. https://wasmedge.org/
[9]
Alex Crichton. 2023. Architecture - Wasmtime. https://docs.wasmtime.dev/contributing-architecture.html#linear-memory
[10]
Martin Fink, Dimitrios Stavrakakis, Dennis Sprokholt, Soham Chakraborty, Jan-Erik Ekberg, and Pramod Bhatotia. 2024. Cage: Hardware-Accelerated Safe WebAssembly.
[11]
Nick Fitzgerald. 2021. rfcs/accepted/benchmark-suite.md ⋅ bytecodealliance/rfcs. https://github.com/bytecodealliance/rfcs/blob/main/accepted/benchmark-suite.md
[12]
Dan Gohman. 2019. wasmtime/docs/WASI-overview.md at main ⋅ bytecodealliance/wasmtime. https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-overview.md
[13]
Google. 2024. V8 JavaScript Engine. https://v8.dev/
[14]
Andreas Haas, Andreas Rossberg, Derek L. Schuff, Ben L. Titzer, Michael Holman, Dan Gohman, Luke Wagner, Alon Zakai, and JF Bastien. 2017. Bringing the Web up to Speed with WebAssembly. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). Association for Computing Machinery, New York, NY, USA, 185–200. isbn:978-1-4503-4988-8
[15]
Intel Corporation. 2023. Intel 64 and IA-32 Architectures Software Developer’s Manual. Intel Corporation, 2200 Mission College Blvd. Santa Clara, CA 95054-1549 USA. https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
[16]
Intel Corporation. 2023. Intel Architecture Instruction Set Extensions and Future Features. 2200 Mission College Blvd. Santa Clara, CA 95054-1549 USA. https://cdrdv2.intel.com/v1/dl/getContent/671368
[17]
C. Lattner and V. Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In International Symposium on Code Generation and Optimization, 2004. CGO 2004. IEEE, San Jose, CA, USA, 75–86. isbn:978-0-7695-2102-2
[18]
S. Lloyd. 1982. Least Squares Quantization in PCM. IEEE Transactions on Information Theory 28, 2 (March 1982), 129–137. issn:0018-9448
[19]
John McCall, Richard Smith, Jason Merrill, and Tom Honermann. 2012. C++ ABI for Itanium: Exception Handling. https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
[20]
Mozilla Corporation. 2024. SpiderMonkey JavaScript/WebAssembly Engine. https://spidermonkey.dev/
[21]
Shravan Narayan, Tal Garfinkel, Mohammadkazem Taram, Joey Rudek, Daniel Moghimi, Evan Johnson, Chris Fallin, Anjo Vahldiek-Oberwagner, Michael LeMay, Ravi Sahita, Dean Tullsen, and Deian Stefan. 2023. Going beyond the Limits of SFI: Flexible and Secure Hardware-Assisted In-Process Isolation with HFI. In Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 3 (Vancouver, BC, Canada) (ASPLOS 2023). Association for Computing Machinery, New York, NY, USA, 266–281. isbn:9781450399180
[22]
Thomas Neumann and Michael J. Freitag. 2020. Umbra: A Disk-Based System with In-Memory Performance. In 10th Conference on Innovative Data Systems Research, CIDR 2020, Amsterdam, the Netherlands, January 12-15, 2020, Online Proceedings. www.cidrdb.org. http://cidrdb.org/cidr2020/papers/p29-neumann-cidr20.pdf
[23]
Oracle. 2022. Adi - Man Pages Section 7: Standards, Environments, Macros, Character Sets, and Miscellany. Technical Report. https://docs.oracle.com/cd/E88353_01/html/E37853/adi-7.html
[24]
Soyeon Park, Sangho Lee, Wen Xu, HyunGon Moon, and Taesoo Kim. 2019. Libmpk: Software Abstraction for Intel Memory Protection Keys (Intel MPK). In 2019 USENIX Annual Technical Conference (USENIX ATC 19). USENIX Association, Renton, WA, 241–254. isbn:978-1-939133-03-8 https://www.usenix.org/conference/atc19/presentation/park-soyeon
[25]
Piotr Sarna. 2022. Wasmtime: Supporting UDFs in ScyllaDB with WebAssembly. https://www.scylladb.com/2022/04/14/wasmtime/
[26]
Konstantin Serebryany, Derek Bruening, Alexander Potapenko, and Dmitriy Vyukov. 2012. AddressSanitizer: A Fast Address Sanity Checker. In 2012 USENIX Annual Technical Conference (USENIX ATC 12). USENIX Association, Boston, MA, 309–318. isbn:978-931971-93-5 https://www.usenix.org/conference/atc12/technical-sessions/presentation/serebryany
[27]
Volodymyr Shymanskyy and Steven Massey. 2024. Wasm3. Wasm3 Labs. https://github.com/wasm3/wasm3
[28]
Moritz-Felipe Sichert. 2024. Efficient and Safe Integration of User-Defined Operators into Modern Database Systems. Ph. D. Dissertation. Technische Universität München, Munich. https://nbn-resolving.de/urn/resolver.pl?urn:nbn:de:bvb:91-diss-20240111-1713746-1-4
[29]
Ben Smith and Andreas Rossberg. 2020. memory64/proposals/memory64/Overview.md at master ⋅ WebAssembly/memory64. https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md
[30]
The Linux man-pages project, Michael Kerrisk, and Alejandro Colomar. 2023-05-03. mprotect(2) — Linux Manual Page. https://man7.org/linux/man-pages/man2/mprotect.2.html
[31]
Wasmer. 2024. Wasmer. https://wasmer.io
[32]
Robert N. M. Watson, Simon W. Moore, Peter Sewell, and Peter G. Neumann. 2019. An Introduction to CHERI. Technical Report 941. University of Cambridge - Computer Laboratory, 15 JJ Thomson Avenue, Cambridge CB3 0FD, United Kingdom. 43 pages. https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-941.pdf
[33]
WebAssembly Community Group and Andreas Rossberg. 2024. Feature Extensions - WebAssembly. https://webassembly.org/features/
[34]
Alon Zakai. 2011. Emscripten: An LLVM-to-JavaScript Compiler. In Proceedings of the ACM International Conference Companion on Object Oriented Programming Systems Languages and Applications Companion. ACM, Portland Oregon USA, 301–312. isbn:978-1-4503-0942-4

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
VMIL '24: Proceedings of the 16th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages
October 2024
74 pages
ISBN:9798400712135
DOI:10.1145/3689490
This work is licensed under a Creative Commons Attribution International 4.0 License.

Sponsors

In-Cooperation

  • SIGAda: SIGAda

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 17 October 2024

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. 64-bit
  2. Bounds Checking
  3. Memory Protection Keys
  4. Virtual Memory
  5. WebAssembly

Qualifiers

  • Research-article

Conference

VMIL '24
Sponsor:

Acceptance Rates

Overall Acceptance Rate 4 of 4 submissions, 100%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 176
    Total Downloads
  • Downloads (Last 12 months)176
  • Downloads (Last 6 weeks)176
Reflects downloads up to 27 Nov 2024

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media