Re:WebAssembly and Back Again: Fine-Grained Sandboxing in Fi...
by bholley on Monday December 06, 2021 @03:12PM
(#29464962)
I believe the implementation in Firefox masks off the high bits of pointers and adds the result to the base address before performing a load/store. This requires us to reserve a power-of-two-sized region of address space, but we can lazily/incrementally commit the pages as the sandboxed code invokes sbrk.
Re:WebAssembly and Back Again: Fine-Grained Sandboxing in Fi...
by azakai on Monday December 06, 2021 @03:49PM
(#29465486)
Thanks for the details bholley!
Do you plan to use the signal handler trick eventually? Less portable but in my tests it shrinks the total overhead by half (from masking's 29% to 14%).
Re:WebAssembly and Back Again: Fine-Grained Sandboxing in Fi...
by bholley on Monday December 06, 2021 @07:36PM
(#29467732)
Sorry, I should have been more clear. I believe we use the masking on 32-bit platforms, which is faster than explicit bounds checks. On 64-bit platforms we use guard pages. We don't actually need a signal handler, because we don't need to gracefully recover from a fault like we do on the Web — we can just crash.
With wasm2c the trapping can be implemented in a variety of ways, for example using the signal handler trick like wasm VMs do (~14% overhead) or manual bounds checks (~42% overhead, but fully portable).