opencontainers / opencontainers/runc
runC can't kill containers containing cgroup-freezer frozen processes
@kolyshkin is already working on this.
Since Sep 8, 2021.
- Dominant language
- Go
- Stars
- 13.5k
- Forks
- 2.3k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 30
Description
As I understand it, runC's procedure for killing a container is to
- Freeze the container's cgroup
- Issue SIGKILL to the process tree
- Unfreeze the container's cgroup
- Wait for the processes to terminate
This occurs in signalAllProcesses() of init_linux.go.
If at the time of this procedure there is a non-empty freezer sub-cgroup with freezer.state==FROZEN, runC will block forever on step 4, because the tasks in that sub-cgroup are still frozen.
This prevents runC containers from safely using freezer groups; e.g. if you try nesting runC, attempting to killing the outer container runs the risk of deadlocking.
I believe I encountered this issue in practice when nesting runC. Specifically, I was attempting to kill a k8s container that itself contained a runC "sub"-container. The issue should also in theory be reproducible by running make test on this repo, and then attempting to docker kill at the wrong moment (specifically, during testing when a nested runC is in the middle the send-signal loop inside signalAllProcesses()).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.