Almost all SFI systems use heavyweight transitions that incur significant performance overhead from saving and restoring registers when context switching between application and sandbox code. We identify a set of zero-cost conditions that characterize when sandboxed code is well-structured enough so that security can be guaranteed via lightweight zero-cost transitions. We show that using WebAssembly (Wasm) as an intermediate representation for low-level code naturally results in a SFI transition system with zero-cost transitions, and modify the Lucet Wasm compiler and its runtime to use zero-cost transitions. Our modifications speed up font and image rendering in Firefox by up to 29.7% and 10% respectively. We also describe a new purpose-built fast SFI system, SegmentZero32, that uses x86 segmentation and LLVM with mostly off-the-shelf passes to enforce our zero-cost conditions. While this enforcement incurs some runtime cost within the sandboxed code, we find that, on Firefox image and font rendering benchmarks, the time saved per transition allows SegmentZero32 to outperform even an idealized hardware isolation system where memory isolation incurs zero performance overhead but the use of heavyweight transitions is required.
翻译:几乎所有SFI系统都使用重量级过渡,在应用和沙箱代码之间的环境转换时,从保存和恢复登记册中产生大量业绩管理费用。我们确定了一套零成本条件,在沙箱代码结构完善的情况下,能够保证安全。我们显示,使用WebAs(Wasm)作为低级代码的中间代表自然导致SFI过渡系统出现零成本过渡,并修改Lucet Wasm编译器及其使用零成本过渡的运行时间。我们的修改使Firefox的字体和图像的转换速度分别加快到29.7%和10%。我们还描述了一个新的目的设计的快速SFI系统(CreactionZero32),它使用x86分解和LLLVM(大部分是现出的通行证)来强制执行我们的零成本条件。虽然这一执行过程在沙箱代码范围内需要一定的运行时间成本,但我们发现,在Firefox图像和字体设定基准的运行时间上,我们节省的时间使得CEpreazeZero32能够超越一个理想的硬件隔离系统,甚至超越了理想化的硬隔离系统,其中要求进行高度的升级。