Skip to content

Remove per-allocation limits and apply repository trust policies - #3245

Draft
Sebastian Thiel (Byron) wants to merge 2 commits into
mainfrom
rust-1.100-alloc
Draft

Sebastian Thiel (Byron) wants to merge 2 commits into
mainfrom
rust-1.100-alloc

Conversation

@Byron

@Byron Byron commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Tasks

  • refackiew

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Summary

Remove the per-allocation limits from pack, index, object database, and commit-graph operations. Remove gitoxide.objects.allocLimit, gitoxide.objects.allocLimitIfReducedTrust, and GIT_ALLOC_LIMIT. Keep fallible reservations and reject impossible counts using the bytes available in packs and index extensions. The allocator experiment and its Rust 1.100 requirement are dropped.

Add gix::open::Options::config_overrides_by_trust() in a separate commit. The callback receives the resolved configuration and final repository trust. Its assignments are appended after file, CLI, API, and environment overrides, with comments that identify the opening policy. Reloads and related opens evaluate the policy for the repository being opened.

The default policy adds no overrides for full trust. Reduced trust disables object and delta caches, sets pack, index, and checkout workers to one, and tightens selected transport, credential, replace-ref, and recursion settings. Explicit transport allowlists and per-submodule fetch settings retain their usual precedence. The policy also records Git verification settings for future support.

Context

Services handling untrusted Git data need to contain memory exhaustion without taking down the server process. Per-allocation caps can stop individual oversized buffers while still allowing memory to accumulate across workers and retained delta bases. The experimental allocator could also turn quota rejection in an infallible collection operation into a process abort. The library keeps the checks that can reject impossible sizes or report failed reservations as errors. Services that need an enforced memory boundary can use worker processes with OS resource limits, as described in SECURITY.md.

Related to #3244, which reports memory retained by pack delta traversal. This change removes the old allocation caps and documents the containment boundary. Aggregate retained-delta accounting is outside its scope.

Validation

  • Pack, index, object database, and commit-graph suites, including parallel pack traversal.
  • Full gix test suite, including policy precedence, final trust, reloads, and related opens.
  • Workspace Clippy across all targets with warnings denied, formatting, and a minimal SHA-1 gix build.
  • Rustdoc with warnings denied and pack and index fuzz-target builds.

@Byron Sebastian Thiel (Byron) changed the title Share measured allocation budgets across plumbing with Rust 1.100 Remove per-allocation limits and apply repository trust policies Nov 25, 2026
Byron needs services to process untrusted Git data without risking the
server process. Per-allocation limits constrain individual buffers but
cannot bound the memory retained across operations, caches, and workers.
A rejecting allocator also makes existing infallible collection operations
abort when a quota is exhausted. Use a separate process with OS resource
limits for that containment guarantee instead.

Remove `alloc_limit_bytes` from pack, index, object-database, commit-graph,
and porcelain APIs, along with `gitoxide.objects.allocLimit`,
`gitoxide.objects.allocLimitIfReducedTrust`, and `GIT_ALLOC_LIMIT`. Remove
the reduced-trust fallback and the separate metadata-limit multiplier.
Retain fallible reservations, checked sizes, and structural validation;
keep allocation failures classified as resource exhaustion. The generic
`gix-error` allocation-limit classification remains available to callers.

Reject pack object counts that cannot fit into the data, bound speculative
delta-tree capacity by the pack size, and reject impossible index-tree
child counts before reserving. Update callers, fixtures, fuzz targets, and
regression coverage. Document process isolation, worker concurrency, and
execution-time limits in `SECURITY.md`.

Replace the measuring-allocator experiment completely, including its
Rust 1.100 requirement, dependencies, and associated adaptations.

Validation:
- `gix-pack`, `gix-index`, `gix-odb`, and `gix-commitgraph` test suites;
  pack tests also pass with parallel traversal enabled
- Repository tests, configuration-tree tests, environment overrides, and
  configuration-cache tests; native FSEvents tests pass outside the sandbox
- Workspace Clippy with all targets and warnings denied; formatting
- Affected API documentation and standalone pack/index fuzz-target builds

Related discussion: #3244

Follow-up CIFuzz validation:
- Keep a 64 MiB decoding budget in the pack fuzz target so malformed
  entry headers cannot make the fuzzer request multi-gigabyte buffers.
  Rejecting the allocation is insufficient because libFuzzer reports
  sanitizer allocation failures before `try_reserve()` can return an error.
- Replayed the CIFuzz out-of-memory artifact and ran the target under ASan
  for 30 seconds without failure. The pack fuzz regression tests pass.
Applications need to reduce resource use and implicit allowances when
opening repositories they do not fully trust. Provide an opening policy
callback that can inspect the resolved configuration and final trust,
including changes due to `safe.directory` and checkout ownership.

Append the assignments as commented `Source::Api` entries after file,
CLI, API, and environment configuration, before caching settings or
creating the object database. Keep the callback in the opening options
so reloads and related repository opens compute their own overrides.

Leave the configuration as resolved for full trust. For reduced trust,
disable object and delta caches, use one worker where configurable, and
set conservative transport, replacement-ref, recursive fetch, and
verification options. Some Git settings are recorded for future support.
Callers can replace the default policy through the builder.

Tests cover override precedence and provenance, late trust changes,
reload and callback errors, and policy inheritance across worktrees.
Validation: the full `gix` test suite, workspace Clippy with warnings
as errors, formatting, and the minimal SHA-1 build passed.
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.

2 participants