Harden Wasmtime's compiled GC code against corruption#13321
Harden Wasmtime's compiled GC code against corruption#13321alexcrichton wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
In the spirit of bytecodealliance#13320 this commit goes through the compiled code for the GC proposal to ensure that, in the face of GC corruption, Wasmtime by default can recover and return a "bug" to the embedder. This was also discussed a bit in bytecodealliance#13112 as well, and the changes made here are: * Plumbing traps from translation into the runtime now uses a new `CompiledTrap` enum instead of just the normal `Trap`. This new enum has branches for `InternalAssert` (not previously present) and additionally `GcHeapCorrupted` (now added). * Whether or not `CompiledTrap::{InternalAssert,GcHeapCorrupted}` is encoded into the final `*.cwasm` is now a `Tunables` configuration option. Internal asserts are not encoded by default but GC heap corruption is. * Traps caught as `CompiledTrap::{InternalAssert,GcHeapCorrupted}` are turned into `WasmtimeBug` and propagated upwards. Traps stay as normal traps. * All memory accesses to the GC heap now use `CompiledTrap::GcHeapCorrupted` as their trap code. Additionally they're also no longer marked as `readonly` in a few places. * A few locations in GC translation using `InternalAssert` now use `GcHeapCorrupted`, such as the checked arithmetic around array lengths. Other assertions which are about control flow are left untouched. The end state is that faults in the GC heap in compiled code itself should show up as a `bug!` on the other end by default. This requires extra metadata in `*.cwasm`s mapping traps, but this is similar to linear-memory-using-wasms which have lots of trap metadata for loads/stores. Being able to catch `InternalAssert` as a first-class error (as opposed to a signal) is a debugging nicety I've added here but remains off-by-default to avoid bloating `*.cwasm`s for internal debugging. Closes bytecodealliance#13112
8a0b0df to
bf9d63e
Compare
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:config"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
DetailsTo modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
In the spirit of #13320 this commit goes through the compiled code for the GC proposal to ensure that, in the face of GC corruption, Wasmtime by default can recover and return a "bug" to the embedder. This was also discussed a bit in #13112 as well, and the changes made here are:
CompiledTrapenum instead of just the normalTrap. This new enum has branches forInternalAssert(not previously present) and additionallyGcHeapCorrupted(now added).CompiledTrap::{InternalAssert,GcHeapCorrupted}is encoded into the final*.cwasmis now aTunablesconfiguration option. Internal asserts are not encoded by default but GC heap corruption is.CompiledTrap::{InternalAssert,GcHeapCorrupted}are turned intoWasmtimeBugand propagated upwards. Traps stay as normal traps.CompiledTrap::GcHeapCorruptedas their trap code. Additionally they're also no longer marked asreadonlyin a few places.InternalAssertnow useGcHeapCorrupted, such as the checked arithmetic around array lengths. Other assertions which are about control flow are left untouched.The end state is that faults in the GC heap in compiled code itself should show up as a
bug!on the other end by default. This requires extra metadata in*.cwasms mapping traps, but this is similar to linear-memory-using-wasms which have lots of trap metadata for loads/stores. Being able to catchInternalAssertas a first-class error (as opposed to a signal) is a debugging nicety I've added here but remains off-by-default to avoid bloating*.cwasms for internal debugging.Closes #13112