-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Podman may kill another processes instead of exec sessions #25104
Comments
Are you able to observe this in podman 5.x or only 1.x? If the latter only, we would not be inclined to fix this. cc @mheon |
Pid reuse is indeed still a large problem across our code base that was never paid much (if any) attention to. In recent kernels pidfds got inode numbers that we can get via stat so it theory we could get the pid and also store the inode number in the db, then when we use we open a pidfd for the pid number and then check if the indoe is still the same. Using the start time itself is still racy as the pid might have exited between our check and when we kill it. We must use pidfs to avoid races. |
Starting with v6.14 you can use pidfd file handles as well ( |
Issue Description
When container is being removed, podman iterates through its exec sessions and checks whether exec session pid is still alive.
The problem is that the pid can be reused for other processes, so that it may not belong to exec session. In this scenario podman may kill another process
I have seen a situation when podman-rm kills itself because pid was assigned to podman-rm itself :)
The result is corrupted podman DB which doesn't allow to create container with same name, but also disallow to remove it because "container has already been removed". Probably, fresher versions of podman can handle this and container will be possible to remove, idk
But still, podman may kill processes it's not supposed to kill - this is the main issue
We have forked version of podman, but looking through the code of latest one it seems to me the issue still exits.
Such problems caused by pid reuse are quite uncommon, but they happen in large clusters
The first idea I came up to fix this is to store process start timestamp as well as pid. Combination of (pid, start) is good enough to determine whether pid belongs to created exec session or not
P.s. We use forked (long time ago) version, but it seems to me, problem is relevant for latest podman as well
Thanks in advance
Steps to reproduce the issue
Steps to reproduce the issue
Describe the results you received
if pid exists it will be killed by podman
Describe the results you expected
pid is not killed because it belongs to another process
podman info output
Podman in a container
No
Privileged Or Rootless
Privileged
Upstream Latest Release
No
Additional environment details
Additional environment details
Additional information
No response
The text was updated successfully, but these errors were encountered: