Skip to content

oci: Handle non-world-readable large files sent as memfd - #362

Merged
cgwalters merged 1 commit into
composefs:mainfrom
cgwalters:fix-layer-copy-perms
Jul 21, 2026
Merged

cgwalters merged 1 commit into
composefs:mainfrom
cgwalters:fix-layer-copy-perms

Conversation

@cgwalters

Copy link
Copy Markdown
Collaborator

We were sending large non-world-readable files as memfd, but the consumer path errored out on these when zerocopy was enforced (because we can't reflink/hardlink a memfd).

Fix this by making that case not an error - any files sent as "inline data" (via memfd) are not candidates for zerocopy.

However, if the caller has CAP_DAC_OVERRIDE, then we can send them as not-inline data, which would also fix the bootc path.

Fixes: bootc-dev/bootc#2324
Assisted-by: AI

We were sending large non-world-readable files as memfd, but
the consumer path errored out on these when zerocopy was enforced
(because we can't reflink/hardlink a memfd).

Fix this by making that case not an error - any files sent
as "inline data" (via memfd) are not candidates for zerocopy.

However, if the caller has CAP_DAC_OVERRIDE, then we can
send them as not-inline data, which would *also* fix the bootc
path.

Fixes: bootc-dev/bootc#2324
Assisted-by: AI
Signed-off-by: Colin Walters <[email protected]>
@cgwalters
cgwalters requested a review from Copilot July 20, 2026 17:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR fixes cstor layer transfer/import behavior for large non-world-readable files that were previously inlined via memfd and could fail when zerocopy was enforced, by ensuring inline (memfd-backed) payloads are treated as non-zerocopyable and by allowing trusted consumers to receive file-backed references instead.

Changes:

  • Extend GetLayerParams with consumer_has_cap_dac_override (defaulting to false) and thread it through producer/consumer paths.
  • Update producer logic to emit FileBackedData for non-world-readable files when the consumer can bypass DAC permissions.
  • Add targeted unit/integration regression tests covering the memfd copy fallback and the DAC-bypass file-backed behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/composefs-storage/src/cstor_service.rs Add CAP_DAC_OVERRIDE-aware request parameter and adjust splitdirfdstream production; add unit test for file-backed emission.
crates/composefs-oci/src/varlink_types.rs Add/serialize new request field with defaults to preserve backward compatibility.
crates/composefs-oci/src/layer_sync.rs Ensure large inline (memfd) payloads always use copy fallback, and add regression test.
crates/composefs-oci/src/cstor.rs Thread new request flag through transfer/import call paths; suppress clippy for expanded signature.
crates/composefs-integration-tests/src/tests/privileged.rs Expand privileged integration fixture to include a non-world-readable large file.
crates/composefs-ctl/src/varlink.rs Update test request construction to use Default for forward-compatible params.
crates/composefs-ctl/src/lib.rs Update request construction to use Default for forward-compatible params.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/composefs-oci/src/cstor.rs Resolved

@jmarrero jmarrero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Johan-Liebert1 Johan-Liebert1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR lgtm, but there are a lot of duplicated structs in varlink_types.rs. Maybe we should move them to a centralized types crate

/// be added in future without breaking old clients.
#[derive(Debug, Clone, Serialize, Deserialize, zlink::introspect::Type)]
#[derive(Debug, Clone, Default, Serialize, Deserialize, zlink::introspect::Type)]
pub struct GetLayerParams {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct is duplicated in varlink_types.rs

@cgwalters
cgwalters added this pull request to the merge queue Jul 21, 2026
Merged via the queue into composefs:main with commit e836ce4 Jul 21, 2026
19 checks 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.

[composefs/unified storage] hardlinking source file into objects directory: Invalid cross-device link (os error 18)

4 participants