Skip to content

fix: handle CNI config stat errors without panic#4890

Open
immanuwell wants to merge 1 commit into
containerd:mainfrom
immanuwell:fix-cni-stat-panic
Open

fix: handle CNI config stat errors without panic#4890
immanuwell wants to merge 1 commit into
containerd:mainfrom
immanuwell:fix-cni-stat-panic

Conversation

@immanuwell
Copy link
Copy Markdown

Small fix for a CNI config path footgun.

If --cni-netconfpath / $NETCONFPATH points at a regular file, fsExists gets a stat error and then derefs a nil FileInfo. Boom: panic. This can happen from a bad local path, no weird infra limit needed.

Repro:

  1. Add TestFSExistsPropagatesStatError from this PR on main.
  2. Run go test ./pkg/netutil -run TestFSExistsPropagatesStatError -count=1.
  3. It panics at pkg/netutil/store.go:56.

This returns the stat error instead, and keeps missing-file behavior intact.

Tests:

  • go test ./pkg/netutil -run TestFSExistsPropagatesStatError -count=1
  • go test ./pkg/netutil -count=1
  • go test ./pkg/...

Signed-off-by: immanuwell <pchpr.00@list.ru>
Copy link
Copy Markdown
Member

@haytok haytok left a comment

Choose a reason for hiding this comment

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

Not sure if the scenario covered by TestFSExistsPropagatesStatError can happen via --cni-netconfpath from the CLI, but if os.Stat returns a non-NotExist error the current code panics on the nil, and returning the error instead is obviously safe. LGTM, Thanks!

@haytok haytok added this to the v2.3.1 milestone May 11, 2026
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