Skip to content

function-wasm-v1.1.0

Latest

Choose a tag to compare

@jonasz-lasut jonasz-lasut released this 23 Nov 12:30
b082a58

function-wasm 1.1.0 moves the runtime to Wasmtime 51.0.0 and function-sdk-rust 0.6.0. Wasmtime 51.0.0 fixes a crash that a module could cause on 1.0.0 to 1.0.2 by declaring a function subtype, so an installation that runs modules it doesn't fully trust should upgrade. The runtime also answers RunFunction with UNAVAILABLE until warm-up ends. The Input, the flags, the manifest and the world are unchanged.

Before you upgrade

From 1.0.0 or 1.0.1, read "Before you upgrade" in the notes of the releases you skip, 1.0.1 and 1.0.2: 1.1.0 contains their fixes and the checks they added.

Check modules that keep dozens of async operations in flight. Wasmtime 51 limits the fibers alive at once in a store to 64 by default (Wasmtime #14971), and Wasmtime 50 had no limit. A fiber backs guest code that Wasmtime calls asynchronously, as the runtime calls run, and the component model's async primitives use more. The runtime keeps the default and gives each run a store of its own, so a run that needs more fibers ends in a fatal result with Wasmtime's store limit of fibers has been reached. The go, python, rust and ts scaffolds pass the guest suite under the limit unchanged.

Security

A module could crash the runtime process

function-wasm 1.0.0 to 1.0.2 link Wasmtime 50.0.1, built without its gc feature. Such a build still accepts the function subtypes of the GC proposal, but the builtin that checks a function against a subtype at run time is a stub that panics, and a panic in compiled code can't unwind. A call_indirect that finds a function of a declared subtype in its table makes that check, and so do the casts the GC proposal adds. The crash ends every request the pod is serving, and a module doesn't need a grant to cause it. Wasmtime 51.0.0 has a working check in every build, and the engine now refuses function subtypes at compile as well (GHSA-rc4p-x33f-vpr2, #432, #435).

Advisories that don't affect function-wasm

Wasmtime 51.0.0 also fixes these advisories against 50.0.1:

Advisory Why function-wasm isn't affected
GHSA-5m8g-xhq4-4h93 A module's stdout and stderr are the host's own, which wasmtime-wasi writes without AsyncWriteStream.
GHSA-f8mm-ggr3-89wh The runtime reads a request body whole and sends it with its own client, which isn't built with HTTP/2. wasmtime-wasi-http's sender is compiled out.
GHSA-43j2-gcp4-m22g GC types are compiled out, and no host function hands a module a GC reference.
GHSA-wvgq-g5hf-6gm6 The runtime keeps Wasmtime's default memory reservation.
GHSA-2674-w29h-wqvj The threads proposal is never enabled.
GHSA-xrvr-8678-5wp8 The runtime never passes a stream or future from one component instance to another.
GHSA-hj27-mpw9-ff4c It affects core modules, and the runtime runs components.
GHSA-f2pq-268w-886c It affects Windows hosts, and the image is Linux.

For operators

RunFunction waits for warm-up

With --warm-modules set, the runtime listens at once and loads the listed modules before it reports ready. 1.0.2 served a RunFunction call that arrived in that time cold. 1.1.0 answers it with UNAVAILABLE (the function is not ready) and runs nothing, so Crossplane fails that reconcile of the composite resource and tries again later. Crossplane's function Deployment has no readiness probe by default. Until a DeploymentRuntimeConfig adds one on /readyz, a composite resource can show rpc error: code = Unavailable desc = the function is not ready while a new pod warms up (Readiness, #422).

Each request is decoded and encoded whole

The runtime now decodes the request and the module's response into the SDK's messages and encodes both again. 1.0.2 decoded them too, but passed on the bytes it had received. Encoding adds host time that grows with the number of composed resources a request has. The difference against 1.0.2 isn't measured (#422).

Large policies and compiled artifacts cost less

A new compositionPolicy compiles outside the lock of the cache that keeps compiled policies, so requests with another policy no longer wait for it: a 200-rule policy takes about 50 ms to compile (#384). The runtime checks a compiled artifact read from disk through a 64 KiB buffer, and no longer reads the whole artifact into memory to check it (#377).

A failed load is retried by one request

After a module failed to load, the requests waiting on that load and a request arriving meanwhile could each fetch and compile the module. One request at a time now retries a failed load, and the others wait for it (#384).

A quantity whose fraction overflows is refused

A limits.memory whose fraction overflowed when multiplied by its suffix wrapped around in a release build, to a value admission still held to --module-memory-limit. The runtime now refuses it with limits.memory "…" is not a valid quantity, and refuses a limits.timeout whose fraction overflows with limits.timeout "…" is not a valid duration (#384).

The timeout outcome of the run histogram

guestfn_module_run_duration_seconds counted a run under timeout when its error contained the deadline sentence, which a module could return in an error of its own. The outcome now comes from how the run ended (Metrics, #384).

For module authors

The runtime re-encodes the request and the response

In 1.0.x, docs/abi-v2.md promised that the host passes the caller's request bytes to run and returns the module's response bytes verbatim. 1.1.0 withdraws that promise: the runtime decodes both and encodes them again. A module receives every field it did before, including fields newer than the runtime's copy of the proto, and can't depend on the layout of the bytes (ABI v2, #422).

Function subtypes and typed function references are refused

docs/abi-v2.md has said since 1.0.0 that the engine refuses GC and function references at compile. The engine didn't: with the gc crate feature off, Wasmtime still accepted function subtypes and call_ref. 1.1.0 switches both proposals off, so a module that uses either fails with cannot compile module: …, as the documentation says. No scaffold or example uses them (ABI v2, #435).

World, Wasmtime and WASI versions

Serves guestfn:function@1.0.0 on Wasmtime 51.0.0: WASI 0.2.12 (cli, clocks, http, io) for the sync scaffolds and WASI 0.3.0 (cli, clocks, http) for the rust scaffold. The world and the WASI versions haven't moved since 1.0.0.

Merged pull requests

Full Changelog: function-wasm-v1.0.2...function-wasm-v1.1.0