Skip to content

fix(initrd): make file mount merges atomic and reject conflicts - #1194

Open
shubhamrai9122-creator wants to merge 1 commit into
urunc-dev:mainfrom
shubhamrai9122-creator:fix/initrd-safe-merge
Open

shubhamrai9122-creator wants to merge 1 commit into
urunc-dev:mainfrom
shubhamrai9122-creator:fix/initrd-safe-merge

Conversation

@shubhamrai9122-creator

Copy link
Copy Markdown

Description

MergeFileMountsIntoInitrd now writes the merged archive to a temporary file next to the initrd and renames it over the initrd on success, keeping its owner and mode. A failed merge leaves the initrd untouched.

It also rejects a file below a regular file, or a file over a directory, with a clear error instead of letting the guest fail at boot. Symlinks are still accepted as parents because they may point at a directory.

TestMergeFileMountsIntoInitrd asserted that the initrd stayed the same file. I removed that assertion because the issue asks for a rename.

Related issues

How was this tested?

In a golang:1.27 Linux container on arm64:

  • go test ./pkg/unikontainers/initrd/ passes as root and as a non-root user.
  • The new failed-merge and conflict tests fail against main.
  • go test ./pkg/unikontainers/ passes as a non-root user. As root, TestCopyFile and TestMoveFile fail, but they fail the same way on main.
  • The hypervisors, unikernels, network and metrics unit tests pass.

golangci-lint v2.15, the version CI uses, reports 0 issues for ./pkg/unikontainers/initrd/.... make lint uses a v2.9 image that can't load this Go version, so I ran v2.15 directly.

I didn't run the e2e tests because they need a Linux host with containerd and the hypervisors installed.

LLM usage

Claude Opus 5.5 (claude-opus-5-5) assisted with the code, the tests and this description.

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

MergeFileMountsIntoInitrd truncated the initrd at its trailer before
writing any new record, so a failed merge left the archive without a
trailer and restarting the same container failed too. Write the merged
archive to a temporary file next to the initrd and rename it over the
initrd on success, keeping the owner and mode of the initrd.

Destinations were also not checked against the existing entries. A file
below a regular file, or a file over a directory, merged successfully
and the guest only failed at boot. Record the type of each entry while
inspecting the archive and reject these destinations with a clear error.
Symlinks are still accepted as parents, since they may point at a
directory.

Fixes: urunc-dev#1107
Signed-off-by: Shubham Kumar <shubhamrai9122@gmail.com>
@netlify

netlify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for urunc ready!

Name Link
🔨 Latest commit d3e161d
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6aee079460bc52bbed99eb82
😎 Deploy Preview https://deploy-preview-1194--urunc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

This branch has not been deployed

No deployments
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.

initrd: file-mount merge can leave the initrd without a trailer or with conflicting entries

1 participant