Skip to content

fix: validate Linux spec early to prevent nil dereference panics#650

Merged
cmainas merged 2 commits into
urunc-dev:main-pr650from
rishi-jat:fix-linux-spec-nil-checks
May 13, 2026
Merged

fix: validate Linux spec early to prevent nil dereference panics#650
cmainas merged 2 commits into
urunc-dev:main-pr650from
rishi-jat:fix-linux-spec-nil-checks

Conversation

@rishi-jat
Copy link
Copy Markdown
Contributor

@rishi-jat rishi-jat commented May 10, 2026

Description

Validate the OCI Linux spec early during container initialization and retrieval to prevent nil dereference panics caused by unsafe access to Spec.Linux.

This change establishes the Linux spec invariant once in:

  • New()
  • Get()

and returns an explicit error when the Linux section is missing.

Additionally, Exec() now guards access to Spec.Linux.Resources.Memory since Resources remains optional even when the Linux spec is present.

Related issues

How was this tested?

gofmt -w pkg/unikontainers/unikontainers.go
go test $(go list ./... | grep -v /tests/e2e)

LLM usage

N/A

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

Copilot AI review requested due to automatic review settings May 10, 2026 04:04
@netlify
Copy link
Copy Markdown

netlify Bot commented May 10, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 1fa0fc2
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a04475ec97747000858218f

@rishi-jat
Copy link
Copy Markdown
Contributor Author

/cc @cmainas

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

@cmainas cmainas left a comment

Choose a reason for hiding this comment

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

Hello @rishi-jat ,

I have added a small comment regarding the new error. Other than it looks ok.

Comment thread pkg/unikontainers/unikontainers.go Outdated
@rishi-jat rishi-jat force-pushed the fix-linux-spec-nil-checks branch from 6391dbd to 3eff01d Compare May 11, 2026 19:51
@rishi-jat
Copy link
Copy Markdown
Contributor Author

Hello @rishi-jat ,

I have added a small comment regarding the new error. Other than it looks ok.

PTAL

@cmainas
Copy link
Copy Markdown
Contributor

cmainas commented May 12, 2026

Thank you @rishi-jat ,

you will need to add yourself in https://github.com/urunc-dev/urunc/blob/main/.github/contributors.yaml and rebase over main too.

@rishi-jat rishi-jat force-pushed the fix-linux-spec-nil-checks branch from 3eff01d to e5d5d42 Compare May 13, 2026 07:15
@rishi-jat
Copy link
Copy Markdown
Contributor Author

\

Thank you @rishi-jat ,

you will need to add yourself in https://github.com/urunc-dev/urunc/blob/main/.github/contributors.yaml and rebase over main too.

DONE , please take a look. Thanks!

@cmainas
Copy link
Copy Markdown
Contributor

cmainas commented May 13, 2026

Hello @rishi-jat ,

please fix the linting errors.

@rishi-jat
Copy link
Copy Markdown
Contributor Author

Hello @rishi-jat ,

please fix the linting errors.

I checked and there are no current lint errors , can you please point out to me am i missing something ?

@cmainas
Copy link
Copy Markdown
Contributor

cmainas commented May 13, 2026

Hello @rishi-jat , please squash your second commit with the first one.

rishi-jat added 2 commits May 13, 2026 15:11
Signed-off-by: Rishi Jat <rishijat098@gmail.com>

fix

Signed-off-by: Rishi Jat <rishijat098@gmail.com>
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
@rishi-jat rishi-jat force-pushed the fix-linux-spec-nil-checks branch from b570500 to 1fa0fc2 Compare May 13, 2026 09:41
@rishi-jat
Copy link
Copy Markdown
Contributor Author

Hello @rishi-jat , please squash your second commit with the first one.

Done, PTAL.

@urunc-bot urunc-bot Bot changed the base branch from main to main-pr650 May 13, 2026 10:25
Copy link
Copy Markdown
Contributor

@cmainas cmainas left a comment

Choose a reason for hiding this comment

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

Thank you @rishi-jat

@cmainas cmainas merged commit 78cbd3b into urunc-dev:main-pr650 May 13, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: add nil checks for optional Linux spec fields to prevent panics

3 participants