Repository navigation
Fix layer extraction of hard links to symlinks - #398
Merged
libracoder merged 1 commit intoNov 16, 2026
Merged
Conversation
Supabase's Nix-built Postgres image hard-links symlinks with absolute targets. tar-rs canonicalizes the final source, so unpacking fails before the container starts. Resolve parent directories through the existing confined inroot helper and create the hard link with linkat flags 0, preserving the source inode without following the final symlink. Cover regular, absolute and dangling symlink sources, symlinked parents, and source/destination escapes.
This was referenced Nov 16, 2026
Closed
libracoder
pushed a commit
that referenced
this pull request
Nov 16, 2026
Supabase's Nix-built Postgres image hard-links symlinks with absolute targets. tar-rs canonicalizes the final source, so unpacking fails before the container starts. Resolve parent directories through the existing confined inroot helper and create the hard link with linkat flags 0, preserving the source inode without following the final symlink. Cover regular, absolute and dangling symlink sources, symlinked parents, and source/destination escapes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes and why
Unpacking Supabase's Nix-built PostgreSQL image fails before the container starts because tar-rs canonicalizes a hard-link source and follows its absolute symlink target outside the temporary layer directory.
Resolve source and destination parents through Kiri's existing confined
inroothelper, then uselinkatwithoutAT_SYMLINK_FOLLOW. This preserves the source inode, including dangling symlinks, while keeping parent resolution inside the layer. The shared Linux guest code covers the Mac VM, Linux and WSL; no dependency or security-check bypass is added.Related: #302 and #322. That PR handles absolute paths in hard-link headers only and leaves relative hard links on tar-rs. The Supabase failure here uses a relative hard-link header pointing to an absolute symlink, so it still needs this fix. This change handles all hard-link entries; there is implementation overlap to coordinate if #322 lands first.
How you tested it
Tested on macOS 26.7.3 (Apple silicon), with Linux guest tests in a disposable privileged Alpine/Rust container.
public.ecr.aws/supabase/postgres:15.8.1.085image now boots, accepts SQL writes/reads, and retains the committed row after restart. Image ID:sha256:a5a0c2b809d5415edff7c010d9facf29063cb138f88ed3a66efdf24b83e79a96.git diff --checkpasses.Full compatibility validation (2026-11-16):
tests/e2e.shcompleted with 550 passed, 0 failed, 6 skipped against the isolated patched Kiri instance. The six skips are installed-instance domain-router checks. An initial completed run had 549 pass / 1 fail on an immediate nginx startup-log assertion; that assertion then passed in 10 targeted repeats and the full second run.Validation limits: Default
cargo fmt --all -- --checkalso fails on unchanged upstream main; this patch retains the surrounding compact layout. Native Windows execution and the complete Supabase Auth/Storage stack were not tested.Rechecked against upstream main
5789abeon 2026-11-16: the affectedlayers.rsis unchanged from the tested base, andgit diff --checkstill passes. The earlier runtime validation above has not been rerun against this newer main.Pattern and behavior audit
A fresh review compared the patch with existing
inroot/sysfilesystem helpers and the pinnedtar 0.4.46hard-link implementation. Confined parent resolution, fd ownership, syscall error handling and test fixtures follow existing patterns. Existing hard-link destination and inode-metadata behavior are preserved. No blocking findings; all 68 Linux guest tests rerun successfully on 2026-11-16.How you found it
AI tools used to write this change: yes — Codex assisted with reproduction, source investigation, implementation, regression tests and PR preparation.
Checklist
cargo clippycomplete successfully (existing upstream warnings; no diagnostics in the changed file)git diff --checkpassescargo fmt --all -- --checkis clean: rerun with Rust 1.97.1 on both versions; unchanged base has 4,319 diff sections, this branch 4,331. New code follows the surrounding compact style too. Making the whole check green would require a separate repository-wide formatting change.