S09-13 - Event Senders
Purpose: How wb-hostd tells the senders of event records about the
audit budgets, what it holds back, and when it stops a VM for its
records.
Requirements: SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.
Design
Section titled “Design”Budget notices
Section titled “Budget notices”wb-netd and wb-proxyd send their records over the event channel
(S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs., “Event records”). When a record puts a VM
over a budget (S09-11-auditS09-11-audit: AuditWhat the audit log records, the budgets that bound it, and what happens when the log can't be written., “Budgets”), wb-hostd sends each sender
of that VM a budget notice with the rule and when it ends. The senders
refuse new work until then. A notice that doesn’t arrive is sent again
with the next record.
The hold
Section titled “The hold”wb-hostd stops reading a sender’s channel while the audit writer
holds its cap of records, and none of the sender’s records is dropped.
The sender’s writes then fail, and it refuses new work with
event-channel-blocked. A budget never holds wb-proxyd’s channel,
which serves every VM. The one other hold is of a wb-netd whose VM’s
stop is decided (“The margin”).
Each sender queues its records until a write succeeds, and drops none.
The queue holds at most 4096 records of up to 4 KiB each, so 16 MiB. At
that cap the sender stops reading guest input, and refuses new work
with event-channel-blocked, until the queue is empty. Only work the
sender admitted adds records, so the per-VM caps on lookups,
connections, streams and requests bound what fills the queue
(S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections., “Events and rate limits” and “Per-VM caps”).
The one exception to the cap is the close of a VM’s hand-off socket
in wb-proxyd: a socket end, a replacement, a reported close, or a
stop (S07-20-handoff-socketsS07-20-handoff-sockets: Hand-off SocketsThe life of one VM's hand-off socket: its identity, the acknowledgments of both ends, how it closes, who a failure is charged to, what each restart does to it, and which of its decisions reach the audit log., S07-21-vm-endS07-21-vm-end: A VM's End in wb-proxydHow wb-hostd ends a VM's hand-off sockets in the one wb-proxyd, and how the VM's last event records reach its stop record without one VM's stop or backlog taking the other VM's network down.). At a close, each stream’s
handler queues one last record past the cap and counts anything more in
a run. A stop adds one record for each of the VM’s open runs and one
stream-end-unrecorded count. The per-VM caps on streams and the rules
that make runs bound them.
The margin
Section titled “The margin”A sender that ignores the notice has its VM stopped. wb-hostd counts
each sender’s records of a VM over a budget on their own, apart from
the other senders’ records of that VM. It counts the records over
either budget in each UTC minute, which makes that count a rate. Over
the bytes budget it also counts their bytes in the budget’s day: the
bytes the audit writer counts against the VM, the length of each
record’s line in the log.
The margin leaves room for the records of work the sender admitted
before the notice: its full queue, and as many again in its socket’s
buffer. So the margin is 8192 records a minute, and over the bytes
budget also 32 MiB a day. When one sender’s count passes either,
wb-hostd stops the VM at once with event-budget-ignored (“Stops for
the audit log”), and logs the rule with the sender and the VM.
wb-hostd writes every record it reads up to the stop decision, the
ones past the margin too. One sender’s records never count toward
another sender’s margin. A wb-netd that ignores its notices can’t
hold wb-proxyd, which serves every VM (T14-shared-proxydT14-shared-proxyd: One proxy process serves both VMsOne wb-proxyd serves the work VM and the isolated VM (S04-architecture, "Processes").).
After the stop decision, until the VM’s events end, wb-hostd holds
the channel of the VM’s wb-netd, which serves that VM alone, until
its stop begins. Then it reads the stop allowance and no more (“At a
VM’s stop”). Each of wb-proxyd’s records of the VM is late from then
on (“Late records”). So a sender that sends on after the decision is
bounded, even when the stop doesn’t take effect.
A sender that stays within the margin is never stopped. Each of a VM’s
two senders may then have 8192 records a minute written past either
budget, and past the bytes budget at most 32 MiB of lines a day. The
count is kept per sender process and per run of the VM. A restarted
wb-netd starts a new count, and the restart limit bounds how many
it gets (S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Restarting a daemon”).
Stops for the audit log
Section titled “Stops for the audit log”wb-hostd stops a VM at once for its audit log with one of these
rules:
audit-write-failedoraudit-free-space: a record of the VM can’t be written, or its data disk grew while the log’s volume is below the floor (S09-11-auditS09-11-audit: AuditWhat the audit log records, the budgets that bound it, and what happens when the log can't be written., “Free space and failed writes”);event-budget-ignored: one sender of the VM passed the margin.
It closes the VM’s run without a stop request the guest could delay,
and the VM’s sessions are lost. It logs the stop with the rule. Such a
stop isn’t an exit of wb-netd or wb-proxyd, so it counts toward no
restart limit (S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Restarting a daemon”). wb-proxyd
isn’t ended or held for it, and the other VM keeps its network.
At a VM’s stop
Section titled “At a VM’s stop”Once a VM’s stop begins, wb-hostd reads its wb-netd’s channel past
the hold, up to a bound, and once the sender exits it reads what it
left, up to the same bound. So the stop record gets the runs wb-netd
flushes at its close, and a VM stop doesn’t wait for the queue
(S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs., “Host work the guest can cause”).
The bound is the stop allowance, one of two exceptions to holding
records back without a drop. A sender that keeps sending after its stop
began has the records past the bound left unread, and wb-hostd logs
that with event-stop-allowance.
At a VM’s stop, wb-hostd reads wb-proxyd’s channel the same way, up
to the last record of the VM that wb-proxyd names at the VM’s end
(S07-21-vm-endS07-21-vm-end: A VM's End in wb-proxydHow wb-hostd ends a VM's hand-off sockets in the one wb-proxyd, and how the VM's last event records reach its stop record without one VM's stop or backlog taking the other VM's network down., “Events in band”). That read’s bound adds the records
the closes of every VM’s sockets may queue past the cap.
Late records
Section titled “Late records”A record from wb-proxyd of a VM whose events already ended, or whose
stop is decided, is late. It isn’t a crash of wb-proxyd, because
ending wb-proxyd would cost every other VM its network. wb-hostd
writes it as its own record and logs it with event-vm-ended. It
doesn’t get a notice or count toward a margin.
Per end of the VM’s slot, wb-hostd writes at most the stop allowance
of late records. After another sender’s overrun stopped the VM, an
honest wb-proxyd’s records of that VM, its end-of-VM records
included, share this allowance. Past that it drops each late record of that slot, the
other exception, and logs the drops with event-vm-ended. So a late
record fails closed for its own VM only (S07-21-vm-endS07-21-vm-end: A VM's End in wb-proxydHow wb-hostd ends a VM's hand-off sockets in the one wb-proxyd, and how the VM's last event records reach its stop record without one VM's stop or backlog taking the other VM's network down., “When
wb-proxyd may name a generation”). At the slot’s next end, and when
the channel closes, and each minute while the count isn’t zero,
wb-hostd writes the exact count of the drops as one audit record with
event-vm-ended. The log then states what it lacks.
Invalid records
Section titled “Invalid records”wb-hostd ends a sender whose record is malformed, or names a VM the
sender may not name, with the rule event-record-invalid. wb-netd
may name only its own VM. wb-proxyd may name a VM that runs, or a
generation at or below its slot’s last ended generation. That takes in
a lower generation that never ran, whose records are late as well, and
leaves out a higher one. A read of the channel that fails otherwise
ends it with event-channel-failed.
Decisions
Section titled “Decisions”Stop the VM, never hold the shared channel
Section titled “Stop the VM, never hold the shared channel”- Why: a hold of
wb-proxyd’s channel for one VM’s budget would refuse every VM’s streams and requests (T14-shared-proxydT14-shared-proxyd: One proxy process serves both VMsOne wb-proxyd serves the work VM and the isolated VM (S04-architecture, "Processes").). Counting the margin per sender keeps one sender’s overrun from counting against another’s records, and stopping the VM bounds what the overrun writes. - Rejected: hold the channel of the last record’s VM past a margin
of all its senders’ records (PR740PR740 (merged): feat(hostd): hold back an event sender that ignores its budgetA compromised network daemon could send well-formed audit records as fast as it liked and ignore every budget notice, and the host daemon would queue them all in memory.). A
wb-netdthat ignores its notices then holdswb-proxydfor every VM. - Decided: I741I741 (closed): Audit event holds: one VM's budget can hold the shared wb-proxyd channel for every VMFollow-up from the reviews of #740 (#541): code review F3, security review F1. (2026-11-10).
Status: Draft