Skip to content

fix: prevent panics and data loss in podman runtime and kernel module check#3146

Open
Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Aprazor:fix/podman-and-kernel-module-errors
Open

fix: prevent panics and data loss in podman runtime and kernel module check#3146
Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Aprazor:fix/podman-and-kernel-module-errors

Conversation

@Aprazor
Copy link
Copy Markdown
Contributor

@Aprazor Aprazor commented Mar 30, 2026

Summary

Four correctness fixes found via code review:

1. Podman extractMgmtIPs — nil dereference panic

After containers.Inspect fails, the code falls through to access inspectRes.Config.Labels which panics on the nil pointer. Fix: return early on error.

2. Podman mount conversion error swallowed — silent data loss

When convertMounts() fails (invalid bind mount syntax), the error was logged but execution continued with mounts = nil. The container was created with no mounts at all — no startup configs, no license files. Fix: propagate the error to fail deployment clearly.

3. Podman memory limit set to zero on parse error

When humanize.ParseBytes fails to parse a memory limit string, the code still set lMem.Limit to the zero value from the failed parse. Fix: only set the limit on successful parse.

4. Kernel module check — file handle leak + empty line panic

IsKernelModuleLoaded leaked the file handle when a module was found (early return without close). Also, an empty line in /proc/modules would panic on Fields()[0] of an empty slice. Fix: use defer f.Close() and guard against empty lines.

Testing

  • go vet ./utils/... — clean
  • go test -race ./utils/... — all pass
  • Podman runtime cannot be compiled on this machine (missing C libs), but changes are syntactically equivalent patterns to existing code

… check

Four fixes:

- runtime/podman/util.go (extractMgmtIPs): after containers.Inspect
  fails, code falls through to access inspectRes.Config.Labels which
  panics on the nil pointer. Return early on error.

- runtime/podman/util.go (toContainerSpec): mount conversion errors
  were logged but not returned. The container was created with no
  mounts, silently losing startup configs and license files. Propagate
  the error so deployment fails clearly.

- runtime/podman/util.go (resourceLimits): when humanize.ParseBytes
  fails to parse a memory limit, the code still set lMem.Limit to the
  zero value from the failed parse. Only set the limit on success.

- utils/kernel_module.go (IsKernelModuleLoaded): file handle leaked
  on the early return path when a module is found. Also, an empty line
  in /proc/modules would panic on index [0] of an empty Fields() slice.
  Use defer for cleanup and guard against empty lines.
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.

1 participant