]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup: prevent spurious transition into non-frozen state
authorRoman Gushchin <guro@fb.com>
Fri, 26 Apr 2019 17:59:44 +0000 (10:59 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 6 May 2019 15:39:06 +0000 (08:39 -0700)
commitb00688e705de2c1ff24dbda4b9eb3eeb4dcaaee7
tree306f73b6b4208a222e4e8e3902d5de62668eb5cb
parent1a650190dcc32520efdac2a05d56a5d9cf21afe9
cgroup: prevent spurious transition into non-frozen state

If freezing of a cgroup races with waking of a task from
the frozen state (like waiting in vfork() or in do_signal_stop()),
a spurious transition of the cgroup state can happen.

The task enters cgroup_leave_frozen(true), the cgroup->nr_frozen_tasks
counter decrements, and the cgroup is switched to the unfrozen state.

To prevent it, let's reserve cgroup_leave_frozen(true) for
terminating processes and use cgroup_leave_frozen(false) otherwise.

To avoid busy-looping in the signal handling loop waiting
for JOBCTL_TRAP_FREEZE set from the cgroup freezing path,
let's do it explicitly in cgroup_leave_frozen(), if the task
is going to stay frozen.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/freezer.c
kernel/signal.c