Skip to content

fix(libcontainer): reject seccomp errnoRet for actions without an errno - #3922

Merged
nayuta723 merged 2 commits into
youki-dev:mainfrom
mateuscmtropical:fix/seccomp-errno-ret-action
Nov 24, 2026
Merged

nayuta723 merged 2 commits into
youki-dev:mainfrom
mateuscmtropical:fix/seccomp-errno-ret-action

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Description

The runtime spec says defaultErrnoRet and errnoRet are only for actions that support an errno, and the runtime must fail otherwise. youki ignored the value for any other action.

The spec validator now rejects defaultErrnoRet and errnoRet unless the action is SCMP_ACT_ERRNO or SCMP_ACT_TRACE, the same check as runc's opencontainers/runc#5564. It runs before the container is created, and the error names the syscall:

seccomp: syscall "mkdir": errnoRet is only supported for the SCMP_ACT_ERRNO and SCMP_ACT_TRACE actions

Every rule is checked, including one that initialize_seccomp later skips because it has the default action (the redundant ALLOW rule from the issue).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)

test_validate_spec_for_seccomp_errno_ret covers ERRNO and TRACE (accepted), ALLOW, KILL, TRAP and LOG (rejected) for both the default action and a rule, plus a rule with the default action.

cargo test -p libcontainer --lib validator: all pass except test_userns_spec_validation, which fails the same way on main in my container (it runs as root). cargo +nightly fmt --check and cargo clippy -p libcontainer --all-targets -- -D warnings are clean.

Related Issues

Fixes #3817

Additional Context

Configs that set an errno on an action without one were accepted before and are now rejected, as the spec requires.

Signed-off-by: mateuscmtropical <mateuscmtropical@gmail.com>

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.

🟢 Approval recommended

No active review issues are recorded for the seccomp errno validation changes.

No open issues 🎉

What changed in this PR

This PR addresses #3817 by validating seccomp errno fields before container creation, rejecting values on actions other than SCMP_ACT_ERRNO and SCMP_ACT_TRACE.

Changes:

  • Validate both default and per-syscall errno fields, including redundant rules that filter initialization later skips.
  • Add validation errors that identify the invalid field and affected syscall names.
  • Add unit tests for accepted and rejected action combinations and rules without errno values.
File Description
crates/​libcontainer/​src/​validator.rs Adds seccomp errno validation to spec checks and unit tests.
crates/​libcontainer/​src/​error.rs Adds errors for invalid default and per-syscall errno fields.

Review effort: Balanced

@nayuta723 nayuta723 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.

Thanks for your contribution!
I left a minor comment. Please take a look.

Comment thread crates/libcontainer/src/error.rs Outdated
IO(#[from] std::io::Error),
#[error("rootless container requires valid user namespace definition")]
NoUserNamespace,
#[error(

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.

Could we combine these into a single error variant since they represent similar errors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 732ec6e. Both checks now return SeccompErrnoRet, and the message names the field, like defaultErrnoRet or errnoRet of syscall "mkdir".

Signed-off-by: mateuscmtropical <mateuscmtropical@gmail.com>

@nayuta723 nayuta723 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, Thanks!

@nayuta723
nayuta723 merged commit 2c12ce0 into youki-dev:main Nov 24, 2026
34 checks passed
@youki-dev-bot youki-dev-bot Bot mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: youki accepts errno values for SCMP_ACT_ALLOW

4 participants