-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libct: fix some container.Run fd leaks, add fd leak test #2802
Merged
Conversation
This file contains 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
kolyshkin
changed the title
Run leaks
libct: fix some container.Run leaks, add fd leak test
Feb 10, 2021
kolyshkin
changed the title
libct: fix some container.Run leaks, add fd leak test
libct: fix some container.Run fd leaks, add fd leak test
Feb 10, 2021
kolyshkin
changed the title
libct: fix some container.Run fd leaks, add fd leak test
[WIP] libct: fix some container.Run fd leaks, add fd leak test
Feb 10, 2021
Looks like by closing fifo fd I have introduced some kind of a race. Looking... |
Looks good to me, thanks for tackling this one 👍 |
2 tasks
kolyshkin
force-pushed
the
run-leaks
branch
2 times, most recently
from
February 10, 2021 21:58
5a28a55
to
ea99c27
Compare
kolyshkin
changed the title
[WIP] libct: fix some container.Run fd leaks, add fd leak test
libct: fix some container.Run fd leaks, add fd leak test
Feb 10, 2021
CI failure in Fedora 33 seems unrelated (filed #2805) -- CI restarted. |
@AkihiroSuda @cyphar @mrunalp PTAL |
AkihiroSuda
previously approved these changes
Feb 24, 2021
Needs rebase. Looks fine otherwise. |
Apparently, the parent never closes execFifo fd. Not a problem for runc per se, but can be an issue for a user of libcontainer. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This is a very simple test that checks that container.Run do not leak opened file descriptors. In fact it does, so we have to add two exclusions: 1. /sys/fs/cgroup is opened once per lifetime in prepareOpenat2(), provided that cgroupv2 is used and openat2 is available. This works as intended ("it's not a bug, it's a feature"). 2. ebpf program fd is leaked every time we call setDevices() for cgroupv2 (iow, every container.Run or container.Set leaks 1 fd). This needs to be fixed, thus FIXME. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Rebased (removed the first patch as it is no longer needed (#2835 implements closing the log pipe). |
mrunalp
approved these changes
Mar 31, 2021
AkihiroSuda
approved these changes
Mar 31, 2021
Merged
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.
this is an alternative for #2794
TL;DR: Fix two cases of fd leaks on run, added a test case to avoid more in the future.
libct: close execFifo after start
Apparently, the parent never closes execFifo fd. Not a problem for runc
per se, but can be an issue for a user of libcontainer.
libct: close log pipe
Otherwise we have one extra fd opened after container.Run.Commit removed (obsoleted by Fix init log forwarding race #2835)
libct/int: add TestFdLeaks
This is a very simple test that checks that container.Run do not leak
opened file descriptors.
In fact it does, so we have to add two exclusions:
/sys/fs/cgroup
directory is opened once per lifetime inprepareOpenat2()
,provided that cgroupv2 is used and openat2 is available. This
works as intended ("it's not a bug, it's a feature").
ebpf program fd is leaked every time we call
setDevices()
forcgroupv2 (iow, every
container.Run
orcontainer.Set
leaks 1 fd).This needs to be fixed in ebpf, thus FIXME (cgroup: devices updates appear to be broken #2366 (comment))
Closes: #2794
Thanks to @cclerget for discovery and the initial fix.
Suggested changelog entry