Skip to content

Disable checkpoint restore codepath when CRIU is not installed - #13664

Merged
samuelkarp merged 3 commits into
containerd:mainfrom
samuelkarp:criu-check-fail-fast
Jul 8, 2026
Merged

samuelkarp merged 3 commits into
containerd:mainfrom
samuelkarp:criu-check-fail-fast

Conversation

@samuelkarp

@samuelkarp samuelkarp commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Checkpoint restore was implicated in several recent CVEs. While those have been patched, it would also be helpful to avoid running the code if it can't be used anyway (i.e., if CRIU isn't installed) or if a node administrator wants to specifically disable it.

Copilot AI 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.

Pull request overview

This PR adds an explicit CRI configuration switch and runtime validation to prevent checkpoint/restore paths from being exercised when CRIU is disabled or not usable, and wires shim-manager environment (notably PATH) into the CRI server to resolve the CRIU binary consistently.

Changes:

  • Introduces disable_criu runtime config and enforces it in CRI checkpoint/restore entrypoints.
  • Plumbs shim-manager environment into the CRI service to resolve criu from the shim-configured PATH (with a fallback to the daemon PATH).
  • Adds unit/integration coverage (Go tests + a contrib e2e script) and runs the new script in CI.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
plugins/cri/cri.go Makes Shim plugin available to CRI init and passes shim environment into CRI service options.
internal/cri/server/service.go Stores shim environment on criService and adds state for CRIU validation caching.
internal/cri/server/container_checkpoint_linux.go Adds CRIU path resolution + validation and gates checkpoint/restore entrypoints on it.
internal/cri/server/container_checkpoint_linux_test.go Adds unit tests for CRIU path resolution and disable/enable gating behavior.
internal/cri/config/config.go Adds DisableCRIU (disable_criu) to CRI runtime configuration.
internal/cri/config/config_unix.go Sets the default DisableCRIU value for Unix defaults.
internal/cri/config/config_windows.go Sets the default DisableCRIU value for Windows defaults.
internal/cri/config/config_test.go Adds a test asserting the default for DisableCRIU is false.
internal/cri/config/disable_criu_test.go Adds TOML parsing coverage for disable_criu.
core/runtime/v2/shim_manager.go Exposes shim-manager environment via an Env() accessor (defensive copy).
contrib/checkpoint/checkpoint-restore-cri-disable-test.sh New e2e-style script validating fail-fast behavior when CRIU is disabled/missing and precedence vs other errors.
.github/workflows/ci.yml Runs the new disable-focused checkpoint/restore validation script in CI (with an ARM exclusion).

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

Comment thread plugins/cri/cri.go Resolved
@dims

ghost commented Jun 25, 2026

Copy link
Copy Markdown
Member

random-ish feedback ... if we are saying that for CRIU to work you have to do:

  • place criu in a path that containerd knows
  • use a flag in config.

then one would expect the flag to be EnableCRIU and leave the default to false ... no? (user has to do 2 things explicitly to make it work basically)

@samuelkarp

ghost commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

The patch set as-is doesn't change the default, so having criu installed and default config makes it work. Default disable would be slightly different and I didn't propose that (yet) since I'd like to be able to cherry pick back to 2.3, 2.2, and 2.1.

Name of the option could go either way though. I'm not at all attached to what it is right now.

@dims

ghost commented Jun 25, 2026

Copy link
Copy Markdown
Member

gotcha @samuelkarp ... am flexible as well. will leave it to you

Comment thread internal/cri/config/config.go Outdated

// DisableCRIU disables CRIU (Checkpoint/Restore In Userspace) support.
// When set to true, checkpoint/restore operations will be disabled.
DisableCRIU bool `toml:"disable_criu" json:"disableCriu"`

ghost Jun 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My 2 cents -- I find double-negatives (disabled=false) harder to reason about than enabled=true

ghost Jun 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, might be worth flipping this to EnableCRIU *bool with a default value of true for now. I agree about the double-negatives.

@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from be18e31 to cc44c5b Compare June 25, 2026 23:25
Copilot Bot review requested due to automatic review settings June 26, 2026 18:25
@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from cc44c5b to ce87133 Compare June 26, 2026 18:25

ghost 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.

Pull request overview

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

Comment thread internal/cri/server/container_create.go Resolved
Comment thread internal/cri/config/config.go Resolved
@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from ce87133 to b3082cc Compare June 26, 2026 21:43
Copilot Bot review requested due to automatic review settings June 26, 2026 22:19
@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from b3082cc to bc1df90 Compare June 26, 2026 22:19

ghost 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Comment thread internal/cri/config/config_test.go Resolved
Comment thread internal/cri/server/container_create.go Resolved
Comment thread internal/cri/config/config.go Resolved
@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from bc1df90 to aca39bb Compare June 26, 2026 22:35
Copilot Bot review requested due to automatic review settings June 26, 2026 23:22
@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from aca39bb to 0acce08 Compare June 26, 2026 23:22

ghost 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.

Pull request overview

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

Comment thread docs/cri/config.md Resolved
@samuelkarp
samuelkarp force-pushed the criu-check-fail-fast branch from 0acce08 to 81a83fa Compare June 26, 2026 23:30
Comment thread internal/cri/config/config.go Resolved
Copilot Bot review requested due to automatic review settings June 29, 2026 05:51
@samuelkarp
samuelkarp requested review from chrishenzie and dims June 30, 2026 22:10

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread internal/cri/config/config.go Resolved
@samuelkarp samuelkarp moved this from Needs Triage to Review In Progress in Pull Request Review Jul 1, 2026
@samuelkarp samuelkarp moved this from Review In Progress to Needs Reviewers in Pull Request Review Jul 1, 2026
sandbox *sandbox.Sandbox,
sandboxConfig *runtime.PodSandboxConfig,
) (ctrID string, retErr error) {
if err := c.checkCriu(); err != nil {

ghost Jul 1, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for my understanding.
This PR seems to do a lot more then just disables criu checkpointing?
Otherwise it'd be as simple as:

if !c.config.EnableCRIU {
    return error.New("criu disabled by administrator")
}

What's the motivation to change criu discovery?

ghost Jul 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think we can (yet) change the default from enable_criu = true to enable_criu = false (I want to do that too, but it'll need deprecation warnings and wouldn't be backportable to our existing releases). But if criu isn't installed, the value of that toggle shouldn't really matter and we can avoid going into the CRIU-related codepaths entirely. If we detect the installation status and can disable the relevant codepath on nodes without criu installed, then this change could be backported to our existing releases.

@github-project-automation github-project-automation Bot moved this from Needs Reviewers to Review In Progress in Pull Request Review Jul 8, 2026
@samuelkarp
samuelkarp added this pull request to the merge queue Jul 8, 2026
Merged via the queue into containerd:main with commit cb66686 Jul 8, 2026
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jul 8, 2026
@samuelkarp

ghost commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/cherry-pick release/2.3
/cherry-pick release/2.2

@k8s-infra-cherrypick-robot

ghost commented Jul 8, 2026

Copy link
Copy Markdown

@samuelkarp: #13664 failed to apply on top of branch "release/2.2":

Applying: cri: validate CRIU availability and version early
Using index info to reconstruct a base tree...
M	core/runtime/v2/shim_manager.go
M	internal/cri/server/container_checkpoint_linux.go
M	internal/cri/server/service.go
M	plugins/cri/cri.go
Falling back to patching base and 3-way merge...
Auto-merging core/runtime/v2/shim_manager.go
Auto-merging internal/cri/server/container_checkpoint_linux.go
Auto-merging internal/cri/server/service.go
CONFLICT (content): Merge conflict in internal/cri/server/service.go
Auto-merging plugins/cri/cri.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 cri: validate CRIU availability and version early

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

ghost commented Jul 8, 2026

Copy link
Copy Markdown

@samuelkarp: new pull request created: #13734

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@samuelkarp samuelkarp added cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch labels Jul 14, 2026
@samuelkarp samuelkarp added cherry-picked/2.1.x PR commits are cherry picked into the release/2.1 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch and removed cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch labels Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) area/criu checkpoint/resume cherry-picked/2.1.x PR commits are cherry picked into the release/2.1 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch size/XL

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants