-
Notifications
You must be signed in to change notification settings - Fork 2.2k
libcontainer: close seccomp agent connection to prevent resource leaks #4796
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
libcontainer: close seccomp agent connection to prevent resource leaks #4796
Conversation
Add missing defer conn.Close(). Signed-off-by: Pavel Liubimov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
I thought the defer done after the type assert would close the connection. But checking the documentation it does not:
File returns a copy of the underlying os.File. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.
I wonder if that code-path can be simplified. But let's start with this fix :)
Test failures seem unrelated, restarted the failed tests |
In fact, we will close all unneeded fds before execve the container process, so it won’t cause resource leaks. But we shouldn't rely too much on this fallback logic. Thanks. |
This is wrong, because the function |
@astrawind Could you help to open backport PRs for |
Exactly, this should be in the parent and not affect the container process.
Not sure I follow, what is the issue? If we start a lot of containers, then we will start the runc parent binary a lot of times, right? I'm not sure I follow your concern here. Can you please elaborate? |
concurrently |
@lifubang yeap, if we start lot of container concurrently, what is the issue? I don't see how it can be a large number of open fds, as each container start creates a new process. |
Without this patch, runc will not release the socket connection after calling syncParentSeccomp (which occurs before the container process starts). If all processes reach this stage simultaneously, it could result in a large number of open file descriptors on the host. This issue becomes particularly significant when a TTY is used for communication with the container, as the associated socket connections may remain open indefinitely until the user logs out of the container. |
@lifubang I don't see it, what am I missing? The process that has this connection open dies when the container starts. And each process won't have more than 1 connection for this. How is it that if a tty is used any of this changes? And what is the issue if several process on the host have one connection open? This connection might be closed when the process dies, but the concurrency is the same if you time it enough to be opened at the same time, even if we do the close. |
Add missing defer conn.Close().