opencontainers / opencontainers/runc

runC can't kill containers containing cgroup-freezer frozen processes

Open
#2,105 0 comments 0 reactions 1 assignee View on GitHub

@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

  1. Freeze the container's cgroup
  2. Issue SIGKILL to the process tree
  3. Unfreeze the container's cgroup
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.