Skip to content

Fix nil pointer dereference in NRI GetIPs#13683

Merged
samuelkarp merged 1 commit into
containerd:mainfrom
chrishenzie:fix-nri-nil-sandbox
Jun 30, 2026
Merged

Fix nil pointer dereference in NRI GetIPs#13683
samuelkarp merged 1 commit into
containerd:mainfrom
chrishenzie:fix-nri-nil-sandbox

Conversation

@chrishenzie

@chrishenzie chrishenzie commented Jun 29, 2026

Copy link
Copy Markdown
Member

Adds a nil guard to GetIPs on criPodSandbox before accessing promoted struct fields on the embedded Sandbox pointer.

During pod sandbox teardown or race conditions during container exit events, nriPodSandbox can return a criPodSandbox instance where the embedded Sandbox pointer is nil.

Assisted-by: Antigravity

Copilot AI review requested due to automatic review settings June 29, 2026 17:18
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Jun 29, 2026

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.

Pull request overview

This PR hardens the NRI CRI pod sandbox wrapper against a teardown/race scenario by preventing a nil pointer dereference when computing IP addresses from a criPodSandbox whose embedded *sstore.Sandbox may be nil.

Changes:

  • Add a nil guard in (*criPodSandbox).GetIPs() before accessing promoted fields from the embedded *Sandbox.
  • Add Linux-scoped unit tests covering nil sandbox, empty primary IP, and populated primary/additional IP cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/cri/nri/nri_api_linux.go Adds p.Sandbox == nil guard in GetIPs() to avoid nil dereference during teardown/races.
internal/cri/nri/nri_api_linux_test.go Adds unit tests validating GetIPs() behavior for nil/empty/populated IP inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cri/nri/nri_api_linux.go
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Jun 30, 2026

@samuelkarp samuelkarp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add the comment that @AkihiroSuda suggested?

@chrishenzie
chrishenzie force-pushed the fix-nri-nil-sandbox branch from 60623bd to 1668da1 Compare June 30, 2026 18:12
Adds a nil guard to GetIPs on criPodSandbox before accessing promoted
struct fields on the embedded Sandbox pointer.

During pod sandbox teardown or race conditions during container exit
events, nriPodSandbox can return a criPodSandbox instance where the
embedded Sandbox pointer is nil.

Assisted-by: Antigravity
Signed-off-by: Chris Henzie <[email protected]>
Copilot AI review requested due to automatic review settings June 30, 2026 18:13
@chrishenzie
chrishenzie force-pushed the fix-nri-nil-sandbox branch from 1668da1 to c2dae31 Compare June 30, 2026 18:13

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@samuelkarp
samuelkarp enabled auto-merge June 30, 2026 18:19
@samuelkarp
samuelkarp added this pull request to the merge queue Jun 30, 2026
Merged via the queue into containerd:main with commit 0c226d2 Jun 30, 2026
48 of 50 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jun 30, 2026
@chrishenzie

Copy link
Copy Markdown
Member Author

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.1

@chrishenzie
chrishenzie deleted the fix-nri-nil-sandbox branch June 30, 2026 20:37
@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@chrishenzie: new pull request created: #13695

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.1

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@chrishenzie: new pull request created: #13696

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.1

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@chrishenzie: new pull request created: #13697

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.1

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@chrishenzie chrishenzie added cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 cherry-picked/2.1.x PR commits are cherry picked into the release/2.1 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch and removed cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/2.1.x PR commits are cherry picked into the release/2.1 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch size/M

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants