Audit — 2026-11-25
On this page
- F1 — A shell overlay rectangle at the wire's floor killed the frame build
- F2 — The typed CLI quoted the wallpaper extension's options into a string
- F3 — A layout clip at a negative width, or a frame at the wire's floor
- F4 — A comment claimed a withdrawal that never happens
- F5 — Every copy a client queued was served in one pass
- F6 — the virtual-keyboard keymap's length was the client's
- Closed — the session lock now has hostile-value probes
- Considered and rejected
- What this pass did not cover
The third pass, and the first that is not about behaviour. The two before read what the compositor does; this one drives the client-reachable protocol surface with the values the wire allows — a hostile client, or merely a buggy one — and asks what a session loses when one arrives. Base 22a2824b, rebased onto main 9576fec9 so the fixes ride the pacing merge; each fix commit ran the pre-commit gate, and the whole branch is green at the tip recorded below. The probes live in crates/viewport/tests/crash_probes.rs and run as part of cargo test --workspace. Every finding here ends the same way: the compositor answers with the protocol's own refusal and a fresh ordinary request still succeeds. A panic, an abort or a wedge fails the suite.
Written after the fixes, so the line numbers are at the fix tip (67ef75c7) rather than at the audited base; where a line moved, the finding names the function instead.
F1 — A shell overlay rectangle at the wire's floor killed the frame build
Crates: crates/viewport. Effort S, risk low. Behavioural.
The rectangle the shell floats above the windows (shell.overlay, apply.rs's arm, and the older single-rectangle screencast.rect) arrived as bare i32s with no bound anywhere. saturating_add kept the page-origin translation from overflowing — the tree has been careful about that since a window on the wrong screen was first worth a comment — but the frame build then subtracts the output's own origin from the rectangle's in raw i32 (state/render_frame.rs's overlay translation). A rectangle at the wire's floor against a monitor at a positive origin is the ordinary side-by-side layout plus a shell that miscounted a notification's position: in a debug build the subtraction panics and takes every later frame build with it, in a release build it wraps and draws and hit-tests the overlay against a nonsense rectangle — the exact fault the saturating translation above it exists to prevent, one line later.
Both arms now keep their rectangles inside the same ±2^20 bound output.configure already keeps every monitor inside, by the same layout_rect_ok (output_management.rs); a rectangle outside it is dropped exactly as a zero-sized one already was, there being no part of it anywhere the compositor could draw or hit-test it. With both origins bounded the subtraction is safe by construction rather than by hoping the shell never miscounts.
How it was verified. tests/crash_probes.rs drove a trusted control-socket client's output.configure to x=100 and a shell.overlay rectangle at x=-2147483648 into the panic at render_frame.rs:701 before the fix, then pinned the frame build surviving it — beside a second client's capture that had to complete, so the frame was really built rather than skipped. On the fix the same cases pass, and an ordinary overlay afterwards still floats.
Fix. 81733d7c, FIXES #72.
F2 — The typed CLI quoted the wallpaper extension's options into a string
Crates: crates/viewport. Effort S, risk low. Behavioural.
The viewport msg CLI typed every bare flag value against one global STRING_FIELDS table, which carried options for the keyboard block's xkb spelling — comma-separated words a keymap is written against. The wallpaper extension's config.wallpaper_options shares that name with a different type: its options is the full options object the settings panel writes back, typed serde_json::Value, documented "as JSON" in docs/ipc.md and pinned as an object by the socket test. The collision meant the typed CLI quoted the object into a string, and the extension — the only reader of the value — was handed a document it cannot parse. That is the one path the settings panel's write-back has from a terminal, so the drift was reachable exactly where the panel itself is not.
Fixed by moving the xkb options into config.keyboard's own per-type strings, the mechanism the tray's id and the rule setters' rules already use for this shape of clash, and leaving the wallpaper's JSON alone. Both spellings are now pinned in config_shell_setters_build_their_fields.
Why this is the same class and worth a commit of its own. FIXES #56 was a CLI row that omitted messages; #70 a row that omitted fields; this is a row that names a field with the wrong type. Three generations of the same omission — nothing ties a row to its variant — and the standing test-gap is recorded in msg.rs: the offered types are derived from the request set, the fields are hand-written.
Fix. b4d49556, FIXES #73.
F3 — A layout clip at a negative width, or a frame at the wire's floor
Crates: crates/viewport. Effort S, risk low. Behavioural.
The clip a shell sends with view.layout was honoured exactly as sent down to negative dimensions — usable_clip's "empty is a crop" branch took anything <= 0 — and the renderer builds the clip's rectangle with a Size that is only ever non-negative. A clip with width -5 was a debug-build panic in that construction and a release-build rectangle whose far edge sat below its origin. The frame rectangle was never bounded anywhere: its coordinates reach the redaction bounds' raw i32 subtraction of the output's origin (beside the border sides that are widened already), so a frame at the wire's floor on a monitor at a positive origin was F1's subtraction on a different path.
A negative clip now means exactly what the documented empty one means — "none of this window" — and is clamped to it on the way in. A frame outside the accepted layout is dropped with a word, the same way a clip that cannot meet its window is already dropped, so the window is still placed and the next layout the shell sends carries a fresh frame.
How it was verified. The clip-and-frame case in tests/crash_probes.rs drove view.layout with a -5 width into the Size panic and a frame at i32::MIN into the redaction subtraction at render_frame.rs:422 before the fix, then pinned an ordinary clip and frame still cropping and bordering after it. The clamp itself is pinned by a_negative_crop_is_the_empty_one_rather_than_a_poisoned_rectangle.
Fix. 93c06614, FIXES #74.
F4 — A comment claimed a withdrawal that never happens
Crates: crates/viewport. No behaviour change.
Not a defect in what the compositor does — a defect in what its own comment told the next reader it does. recovery.rs's comment on a fresh DrmLeaseState claimed the old device's Drop "withdraws" the lease global. Smithay's Drop ends the leases and finishes the lease-device objects its clients hold; nothing in the crate withdraws the global, and a stale one stays advertised until the card's slot is replaced. A fresh bind against it is what drm_lease_state's empty fallback and lease_request's refusal exist to catch. This pass read the comment first and would have reasoned from a withdrawal that never happens, which is why it is a finding with a commit rather than a note: the next audit starts where this one stopped.
Fix. 1bcc6883 (comment only, no FIXES entry).
F5 — Every copy a client queued was served in one pass
Crates: crates/viewport. Effort S, risk low. Behavioural.
queue_copy pushed every zwlr_screencopy_v1 copy onto pending_copies with no bound, and the service pass took every entry for the output and composited it offscreen and read it back, one after another. One client may ask for thousands in a single flush — the protocol has no flow control — and the main loop then spends frame after frame on a backlog nobody will look at while input and every other client wait behind it: a session that has stopped answering without having crashed, which is harder to notice and just as lost. The ext-image-copy-capture door (pending_capture_frames) held frames the same way with the same per-entry cost.
Both queues now hold at most eight entries — per output for copies, across sessions for frames — and an entry past the bound is told failed, the protocol's own word for a copy that will not be served, rather than held. This is the same bound the tree already puts on clipboard readers and writers and on screenshot encoders; the door was the one client-driven queue that had none.
How it was verified. a_flood_of_queued_copies_is_refused_not_served queues thirty-two copies of one buffer in one flush and pins that the excess is refused, that the session survives, and that an ordinary capture is still served afterwards. With the bound removed the same probe serves all thirty-two and refuses none.
Fix. 67ef75c7, FIXES #75.
F6 — the virtual-keyboard keymap's length was the client's
A client binds zwp_virtual_keyboard_manager_v1 (offered to native, non-sandboxed clients — state.rs:1712) and sends keymap with a memfd and a size it chooses. Smithay's dispatch (src/wayland/ virtual_keyboard/mod.rs:237-247 in the fork) called compile_keymap(fd, size), which asked xkbcommon to map the descriptor for exactly that many bytes (xkbcommon 0.9.0, Keymap::new_from_fd — MmapOptions:: new().len(size).map_copy_read_only(...)) and then read the mapping as a keymap string. mmap accepts a length past the end of a file; the read that follows was what faulted, and the fault was SIGBUS, not a returned error. An eight-byte memfd with size = 0xFFFFFFFF was the whole attack, and the result was the session gone with nothing logged and nothing to unwind.
It could not be fixed in this crate: the mapping happened inside Smithay's Dispatch for zwp_virtual_keyboard_v1, before process_virtual_ keyboard_event was called (input.rs, our handler). The fork's compile_keymap now refuses zero or over-1-MiB keymaps, requires a regular file whose length covers the declaration, copies exactly that many bytes from offset zero, and compiles the owned UTF-8 buffer with Keymap::new_from_string. The snapshot matters as much as the first check: SCM_RIGHTS shares the open file description, so a client could truncate the memfd after fstat and turn a retained mmap into the same SIGBUS. A positional read either returns the stable bytes or an error; it cannot fault on a later truncate. The dispatcher still leaves an earlier valid keymap in place when the new one is refused.
How it was verified. Eight module-local Smithay tests cover a declared length past EOF, zero, MAX_KEYMAP_SIZE + 1 and the exact u32::MAX input, a file truncated before validation, a write-only descriptor that reaches the read-error path, a non-regular descriptor, invalid UTF-8 and malformed XKB. Two compatibility cases pin offset-zero reads and ignored trailing bytes. Viewport's workspace clippy and test gates were also run against the pinned fork commit.
Integration. Fixed in the Smithay fork at e61b7f7a; both Viewport Smithay pins and the lockfile now name that commit.
Closed — the session lock now has hostile-value probes
handlers/session_lock.rs keys lock_surfaces by output name, and the render path looks a surface up by the same name; the accepted locker is the only one whose surfaces are drawn. The functional suite originally drove one lock and one unlock, leaving the protocol's hostile sequences uncovered: get_lock_surface twice on one output, unlock_and_destroy followed by a new lock, a surface with a buffer attached before get_lock_surface (the AlreadyConstructed error), and a locker that never draws.
The follow-up pass closed the gap. tests/lock-lifecycle.test.sh now drives those sequences, including stale surfaces and stale unlocks, and pins that a superseded locker receives finished, a committed buffer is refused with already_constructed, and only the accepted locker's surfaces receive frame callbacks and input. The headless frame timer presents lock surfaces on every virtual output. FIXES #92–#94 and the accompanying changelog entries carry the three defects the probes exposed.
Considered and rejected
- The ghost's slide distance can overflow on a box at the wire's edge. It cannot.
close_slide_distance(state/ghost.rs) runs only after the box has been found to overlap an output's geometry, and that overlap bounds the box'sxfrom above: an overlapping box satisfiesx < output.x + output.w, andoutput_geometryis itself inside the accepted layout (±2^20). Withxso bounded,x + w/2cannot overflow, the first branch'sx + w - output.xcannot either, and the second branch's magnitude is at most the output's right edge minus axthat cannot be more negative thanoutput_centre - w/2for the branch to be taken. The arithmetic is safe under the guard the caller already applies; a saturating rewrite would be noise. - Window capture negates a client-controlled geometry origin. It cannot be reached.
Window::geometry()is the client'sset_window_geometryintersected with the window's bounding box (Smithaydesktop/wayland/window.rs), and the intersection clamps the origin into the bbox, so the wire's floor never survives to the negation instate/screencast.rs. A subsurface placed at the wire's floor was also driven —a_subsurface_at_the_wire_floor_cannot_kill_ the_sessionintests/crash_probes.rs— and the window's bounding-box arithmetic survives it, so the probe stays as a passing pin rather than a reproduction. - The popup offset sum in the same capture path. Same class as the negation and traced to the same guard: the positioner's offset is the client's, but the window's geometry is clamped by the intersection above, and no reproduction reached an overflow. The wide arithmetic a fix would add is not justified by a defect this pass could show.
What this pass did not cover
The portal D-Bus session lifecycles (frontend-gated, not reachable by a bare peer), Xwayland's drag and _NET_WM_STATE paths, idle and inhibit over the bus, wl_region and surface-tree shapes that cost CPU rather than crash, and any defect that lives in the Smithay fork rather than in this crate. The keymap was the one such defect this pass found; F6 records the fork-side fix and completed Viewport pin bump. Numbers for F1–F5 are at 67ef75c7; the original pass's gate was the repository's own, not a subset: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, and both wpe configurations, run by the pre-commit hook on every fix commit.