Skip to content

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

@Yashika0724

Description

@Yashika0724

Problem

urunc dereferences Spec.Linux and its sub-fields in several locations without nil checks:

  • pkg/unikontainers/unikontainers.go:334 — u.Spec.Linux.RootfsPropagation
  • pkg/unikontainers/unikontainers.go:457 — u.Spec.Linux.Namespaces
  • pkg/unikontainers/unikontainers.go:639 — u.Spec.Linux.Namespaces
  • pkg/unikontainers/unikontainers.go:828 — u.Spec.Linux (namespace config)

Per the OCI runtime-spec, the linux object is platform-specific and optional. A spec-compliant
config bundle may omit this field entirely, and the runtime should handle this gracefully rather
than panic.


Proposed Fix

Add defensive nil checks before dereferencing Spec.Linux, falling back to safe defaults and
skipping namespace operations when Linux config is absent.

This is defensive hardening and does not change behavior for any currently working workload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreRelated to urunc's internalsbugSomething isn't working

    Type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions