Skip to content

Conversation

@helsaawy
Copy link
Contributor

Fix bug where internal/guest/runtime/runc/container.go code assumed that the logfile passed to runc would contain an error without checking. This can result in scenarios where cmd.Run (or cmd.CombinedOutput) returns a non-nil err but (due to a runc's failure to start or write to the log file, or the JSON is invalid) runcErr is nil and therefore the error returned by errors.Wrapf is also nil.
Those scenarios can ultimately panic since it violates invariants where a nil error is assumed to mean a successful operation or a usable return value.

Fix this by guarding on runcErr == nil and warn in those situations.

Fix bug where `internal/guest/runtime/runc/container.go` code assumed
that the logfile passed to runc would contain an error without checking.
This can result in scenarios where `cmd.Run` (or `cmd.CombinedOutput`)
returns a non-nil `err` but (due to a runc's failure to start or
write to the log file, or the JSON is invalid) `runcErr` is nil and therefore
the error returned by `errors.Wrapf` is also nil.
Those scenarios can ultimately panic since it violates invariants where
a nil error is assumed to mean a successful operation or a usable return
value.

Fix this by guarding on `runcErr == nil` and warn in those situations.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@helsaawy helsaawy requested a review from a team as a code owner December 17, 2025 21:56
@helsaawy helsaawy merged commit d2114c6 into microsoft:main Dec 18, 2025
17 checks passed
@helsaawy helsaawy deleted the runc-log-err branch December 18, 2025 16:53
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