Skip to content

moca-egress: async bounded audit, and bounded conn_cap refusals per VM #586

Closed

Description

@pdettori

Follow-up from the #583 review (comment #583 (comment)), deferred out of that PR by agreement.

1. Cap refusals are unbounded. Each connection over MOCA_EGRESS_MAX_CONNS_PER_VM emits a conn_cap audit line and spawns a goroutine that holds the socket for up to ~2 s (writeAndClose: 1 s write plus 1 s drain). A guest connecting in a tight loop can:

  • exhaust host-wide fds in this single shared process (LimitNOFILE=65536);
  • flood stdout, so that journald's per-service rate limit (default 10000/30 s) drops other VMs' audit events.

Proposed: bound concurrent cap refusals per VM (close without drain on overflow), and coalesce conn_cap events per VM per interval.

2. Audit can stall the proxy. Audit.Emit writes synchronously to stdout and is called under pc.mu, including from abort() via Unregister. A stalled journald therefore blocks Unregister and Close, and with them the control socket. That contradicts the "auditing must not stall the proxy" comment.

Proposed: a bounded async queue with a drop counter, plus a periodic audit_dropped event when anything was dropped.

Related: #277, #583.

Activity

  1. self-assigned this
    on Oct 26, 2026
  2. added 2 commits that reference this issue on Oct 26, 2026
    87cc3fe
    aefd09f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions