Skip to content

criu: validate --parent-path#1742

Merged
giuseppe merged 1 commit intocontainers:mainfrom
kolyshkin:criu-2
May 8, 2025
Merged

criu: validate --parent-path#1742
giuseppe merged 1 commit intocontainers:mainfrom
kolyshkin:criu-2

Conversation

@kolyshkin
Copy link
Copy Markdown
Collaborator

@kolyshkin kolyshkin commented May 8, 2025

The --parent-path argument should be relative to image path, or CRIU will fail with not very helpful error message, like ENOENT.

Add validation of --parent-path and helpful errors.

This is similar to 1 and fixes the runc test named "checkpoint --pre-dump (bad --parent-path)".

Summary by Sourcery

Add validation for the --parent-path argument in CRIU checkpoint to ensure it is a valid, relative directory path

Bug Fixes:

  • Prevent CRIU from failing with unclear error messages by validating the parent path beforehand

Enhancements:

  • Add comprehensive validation for the --parent-path argument before passing it to CRIU

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 8, 2025

Reviewer's Guide

This pull request enhances the CRIU checkpointing functionality by adding validation for the --parent-path argument. The implementation checks if the provided path is relative and if it points to an existing directory before passing it to CRIU, returning specific error messages if validation fails.

File-Level Changes

Change Details Files
Added validation for the --parent-path argument to ensure it is a relative path and a valid directory.
  • Checked if cr_options->parent_path starts with '/' to ensure it is relative.
  • Used crun_dir_p_at to verify that cr_options->parent_path is a valid directory relative to the image path.
  • Returned specific error messages for invalid path format, non-existent path, or if the path is not a directory.
src/libcrun/criu.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @kolyshkin - I've reviewed your changes - here's some feedback:

  • Consider propagating errno in crun_make_error when crun_dir_p_at fails, to provide a more specific system error message than just 'invalid --parent-path'.
  • Consider adding a check to ensure --parent-path is not an empty string, as CRIU likely expects a non-empty path component.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

The --parent-path argument should be relative to image path, or CRIU
will fail with not very helpful error message, like ENOENT.

Add validation of --parent-path and helpful errors.

This is similar to [1] and fixes the runc test named
"checkpoint --pre-dump (bad --parent-path)".

[1]: opencontainers/runc#2913

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Copy link
Copy Markdown
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit 16b7ae4 into containers:main May 8, 2025
48 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.

2 participants