Repository navigation
oci: Handle non-world-readable large files sent as memfd - #362
Conversation
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]>
There was a problem hiding this comment.
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
GetLayerParamswithconsumer_has_cap_dac_override(defaulting tofalse) and thread it through producer/consumer paths. - Update producer logic to emit
FileBackedDatafor 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.
Johan-Liebert1
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
This struct is duplicated in varlink_types.rs
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