Skip to content

seccomp: apply all argument conditions - #2220

Open
giuseppe wants to merge 2 commits into
containers:mainfrom
giuseppe:seccomp-no-hardcoded-limit
Open

seccomp: apply all argument conditions#2220
giuseppe wants to merge 2 commits into
containers:mainfrom
giuseppe:seccomp-no-hardcoded-limit

Conversation

@giuseppe

@giuseppe giuseppe commented Sep 1, 2026

Copy link
Copy Markdown
Member

remove the arbitrary limit of 6 conditions.

@eriksjolund PTAL

@giuseppe
giuseppe marked this pull request as ready for review September 1, 2026 12:42
@giuseppe
giuseppe requested a review from kolyshkin September 2, 2026 15:15

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

Review of the seccomp argument handling. Three findings, one of them a behaviour change beyond the stated fix.

Note: this comment was generated by an AI assistant (Claude) at the request of a reviewer; please double-check it.

Comment thread src/libcrun/seccomp.c
Comment thread src/libcrun/seccomp.c
Comment thread src/libcrun/seccomp.c Outdated
{
size_t r;
const size_t args_len = seccomp->syscalls[i]->args_len;
cleanup_free struct scmp_arg_cmp *arg_cmp = xmalloc (sizeof (*arg_cmp) * args_len);

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.

args_len can be 0 here: libocispec sets syscalls[i]->args to a non-NULL calloc(len + 1, ...) even for an empty JSON array (libocispec/src/ocispec/runtime_spec_schema_defs_linux.c:525), so a config containing "args": [] takes the else branch of args == NULL with args_len == 0. xmalloc(0) calls malloc(0), which the C standard permits to return NULL, and xmalloc then calls OOM() and aborts the runtime.

Beyond that the allocation is unnecessary: this branch is only reached when multiple_args is false, which means every index is distinct and < 6, so args_len <= 6 is provable -- the previous fixed struct scmp_arg_cmp arg_cmp[6] was both correct and cheaper. The suggestion in the other comment goes back to the fixed array.

Note: this comment was generated by an AI assistant (Claude) at the request of a reviewer; please double-check it.

@giuseppe
giuseppe force-pushed the seccomp-no-hardcoded-limit branch from a1900d3 to d4d7de4 Compare September 4, 2026 07:15
remove the arbitrary limit of 6 conditions.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
giuseppe force-pushed the seccomp-no-hardcoded-limit branch from d4d7de4 to 9d15f51 Compare September 4, 2026 09:19
Harden the seccomp cache key.  The cache is keyed by a checksum of the
configuration, but some inputs that change the generated filter were
missing or ambiguously encoded, so in principle a stale filter could be
reused.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@eriksjolund

Copy link
Copy Markdown
Contributor

LGTM

@giuseppe

Copy link
Copy Markdown
Member Author

@kolyshkin fine to merge this?

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.

3 participants