fix: close namespace fd after Setns in joinSandboxNetNs#681
Closed
Atishyy27 wants to merge 1 commit into
Closed
Conversation
✅ Deploy Preview for urunc canceled.
|
85f3514 to
cf85484
Compare
Fixes urunc-dev#673 Signed-off-by: Atishyy27 <sethatishayjain@gmail.com>
cf85484 to
dd25f51
Compare
Contributor
Author
|
Closing as duplicate |
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.
Description
Fixes file descriptor leak in
joinSandboxNetNs()by addingdefer unix.Close(fd)immediately after opening the namespace file descriptor.Problem
The function opens a file descriptor to the network namespace but never closes it. Since
Kill()returns normally (no exec happens), theO_CLOEXECflag doesn't help. The fd stays open through the rest ofdelete --force(Delete()+ExecuteHooks("Poststop")), keeping the namespace reference alive after the VMM is already dead.Solution
Add
defer unix.Close(fd)right after theunix.Open()call and error check. This follows the same pattern used in:vishvananda/netnsruncClosing the fd after
Setnsis safe and won't pull the thread out of the namespace.Related issues
joinSandboxNetNs#673How was this tested?
Development environment is Windows, so local build/test was not possible (urunc requires Linux syscalls). The fix follows established patterns from
vishvananda/netnsandrunc. CI tests will validate on Linux.LLM usage
Claude 3.7 Sonnet (via claude.ai) was used to:
Checklist
make lint). (Unable to test on Windows)