Skip to content

Avoid closing unrelated descriptors when spawning fails early#44

Merged
guillerodriguez merged 1 commit into
masterfrom
fix/process-failed-exec-should-not-close-unrelated-fds
Jul 16, 2026
Merged

Avoid closing unrelated descriptors when spawning fails early#44
guillerodriguez merged 1 commit into
masterfrom
fix/process-failed-exec-should-not-close-unrelated-fds

Conversation

@guillerodriguez

Copy link
Copy Markdown
Contributor

VMProcess.nativeSpawn() can fail before calling cpproc_forkAndExec() (null/empty command array, string extraction failure, malloc failure). Since fds[] is not initialized, the cleanup path could end up closing up to three arbitrary live descriptors.

Initialize every descriptor to -1 at declaration so all early failure paths are safe.

VMProcess.nativeSpawn() can fail before calling cpproc_forkAndExec()
(null/empty command array, string extraction failure, malloc failure).
Since fds[] is not initialized, the cleanup path could end up closing
up to three arbitrary live descriptors.

Initialize every descriptor to -1 at declaration so all early failure
paths are safe.

Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
@guillerodriguez
guillerodriguez requested a review from phvega July 14, 2026 10:33
@guillerodriguez
guillerodriguez merged commit 89cea25 into master Jul 16, 2026
3 checks passed
@guillerodriguez
guillerodriguez deleted the fix/process-failed-exec-should-not-close-unrelated-fds branch July 16, 2026 10:52
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.

2 participants