Skip to content

fix(native-sidecar): close maxFilesystemBytes gaps on host-backed writes#1813

Open
NathanFlurry wants to merge 1 commit into
stack/docs-load-testing-correct-the-ledger-after-adversarial-review-xwxulsumfrom
stack/fix-native-sidecar-close-maxfilesystembytes-gaps-on-host-backed-writes-tksxsmyt
Open

fix(native-sidecar): close maxFilesystemBytes gaps on host-backed writes#1813
NathanFlurry wants to merge 1 commit into
stack/docs-load-testing-correct-the-ledger-after-adversarial-review-xwxulsumfrom
stack/fix-native-sidecar-close-maxfilesystembytes-gaps-on-host-backed-writes-tksxsmyt

Conversation

@NathanFlurry

Copy link
Copy Markdown
Member

Review found the mapped-host budget check barely constrained a real guest:

  • fs.writeFile/writeFileSync and fs.copyFile allocate no fd, so they never
    reached the fd-based check at all. writeFileSync is the most common Node
    write API: a single 8 GB write succeeded under a 64 MiB cap. Both now
    check before writing (O_TRUNC, so the resulting size is the payload size).

  • The fd check failed OPEN: metadata() errors defaulted the current size to
    0, so an append was measured from offset 0 and any file size passed. An
    enforcement check that fails open is worse than none, because it reads as
    enforced. It now fails closed.

  • ftruncate: VERIFIED NOT a bypass, contrary to one review claim. The kernel
    truncate applies the quota and the single construction site always supplies
    a guest path. Added a fail-closed guard so a future guest_path: None
    caller cannot silently disable enforcement for truncation.

All host-backed writes now funnel through one admission point,
check_mapped_host_write_budget, so the per-VM aggregate has a single place
to land. That aggregate is still MISSING: the budget remains per-file while
the kernel side compares against whole-filesystem usage, so a guest can still
exceed its VM budget by spreading bytes across many files. Documented on the
function.

Review found the mapped-host budget check barely constrained a real guest:

- fs.writeFile/writeFileSync and fs.copyFile allocate no fd, so they never
  reached the fd-based check at all. writeFileSync is the most common Node
  write API: a single 8 GB write succeeded under a 64 MiB cap. Both now
  check before writing (O_TRUNC, so the resulting size is the payload size).

- The fd check failed OPEN: metadata() errors defaulted the current size to
  0, so an append was measured from offset 0 and any file size passed. An
  enforcement check that fails open is worse than none, because it reads as
  enforced. It now fails closed.

- ftruncate: VERIFIED NOT a bypass, contrary to one review claim. The kernel
  truncate applies the quota and the single construction site always supplies
  a guest path. Added a fail-closed guard so a future `guest_path: None`
  caller cannot silently disable enforcement for truncation.

All host-backed writes now funnel through one admission point,
check_mapped_host_write_budget, so the per-VM aggregate has a single place
to land. That aggregate is still MISSING: the budget remains per-file while
the kernel side compares against whole-filesystem usage, so a guest can still
exceed its VM budget by spreading bytes across many files. Documented on the
function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant