fix: prevent panics and data loss in podman runtime and kernel module check#3146
Open
Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Open
fix: prevent panics and data loss in podman runtime and kernel module check#3146Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four correctness fixes found via code review:
1. Podman
extractMgmtIPs— nil dereference panicAfter
containers.Inspectfails, the code falls through to accessinspectRes.Config.Labelswhich 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 withmounts = 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.ParseBytesfails to parse a memory limit string, the code still setlMem.Limitto 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
IsKernelModuleLoadedleaked the file handle when a module was found (early return without close). Also, an empty line in/proc/moduleswould panic onFields()[0]of an empty slice. Fix: usedefer f.Close()and guard against empty lines.Testing
go vet ./utils/...— cleango test -race ./utils/...— all pass