Skip to content

fix(build): copy kernel module symlinks verbatim - #171

Open
RaphaelFakhri wants to merge 1 commit into
earendil-works:mainfrom
RaphaelFakhri:fix/kernel-module-verbatim-symlinks
Open

RaphaelFakhri wants to merge 1 commit into
earendil-works:mainfrom
RaphaelFakhri:fix/kernel-module-verbatim-symlinks

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes #163.

copyAllKernelModules copies the initramfs kernel modules into the rootfs with fs.cpSync(..., { dereference: false }). Without verbatimSymlinks: true, Node still resolves each symlink target against the host:

  • Relative targets such as link.ko -> target.ko are rewritten into absolute paths inside the temporary build directory, which do not exist in the guest.
  • Targets inside unreadable host directories make Node abort with filesystem_error: Permission denied.

This change passes verbatimSymlinks: true so module symlinks keep their original targets. It adds a test in host/test/oci-rootfs-safety.test.ts that checks a relative and an absolute module symlink survive syncKernelModules unchanged, plus a CHANGELOG.md entry.

Test: node --test test/oci-rootfs-safety.test.ts fails without the fix (actual: '/tmp/.../initramfs/lib/modules/6.18.9-0-virt/kernel/target.ko', expected 'target.ko') and passes with it (10/10). make -C host lint and make -C host typecheck are clean.

Contribution Agreement

Please ensure this PR follows the guidelines in CONTRIBUTING.md.

By submitting this pull request, I confirm the following:

I understand that the entity Earendil Inc. (incorporated in the state of Delaware in 2025) needs some rights from me in order to utilize my contributions in this PR. As a contributor I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Earendil Inc. can use, modify, copy, and redistribute my contributions, under Earendil Inc.'s choice of terms.

copyAllKernelModules used fs.cpSync with dereference: false but without
verbatimSymlinks, so Node resolved guest symlink targets against the
host. Relative targets were rewritten into absolute host paths that do
not exist in the guest, and targets inside unreadable host directories
aborted the process.

Fixes earendil-works#163

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.

Kernel-module copying resolves guest symlinks against the host and can abort Node

1 participant