Skip to content

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

Open
rishi-jat wants to merge 2 commits into
urunc-dev:mainfrom
rishi-jat:fix-linux-spec-nil-checks
Open

fix: validate Linux spec early to prevent nil dereference panics#650
rishi-jat wants to merge 2 commits into
urunc-dev:mainfrom
rishi-jat:fix-linux-spec-nil-checks

Conversation

@rishi-jat
Copy link
Copy Markdown

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

Signed-off-by: Rishi Jat <rishijat098@gmail.com>
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 ready!

Name Link
🔨 Latest commit 3eff01d
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a023342cc3e060008968ad7
😎 Deploy Preview https://deploy-preview-650--urunc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rishi-jat
Copy link
Copy Markdown
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
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
@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
Author

Hello @rishi-jat ,

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

PTAL

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.

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

3 participants