Skip to content

Commit

Permalink
cgroup: Prevent kill_css() from being called more than once
Browse files Browse the repository at this point in the history
The kill_css() function may be called more than once under the condition
that the css was killed but not physically removed yet followed by the
removal of the cgroup that is hosting the css. This patch prevents any
harmm from being done when that happens.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org # v4.5+
  • Loading branch information
Waiman Long authored and Tejun Heo committed May 17, 2017
1 parent 2ea659a commit 33c35aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/cgroup-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum {
CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
CSS_RELEASED = (1 << 2), /* refcnt reached zero, released */
CSS_VISIBLE = (1 << 3), /* css is visible to userland */
CSS_DYING = (1 << 4), /* css is dying */
};

/* bits in struct cgroup flags field */
Expand Down
5 changes: 5 additions & 0 deletions kernel/cgroup/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4265,6 +4265,11 @@ static void kill_css(struct cgroup_subsys_state *css)
{
lockdep_assert_held(&cgroup_mutex);

if (css->flags & CSS_DYING)
return;

css->flags |= CSS_DYING;

/*
* This must happen before css is disassociated with its cgroup.
* See seq_css() for details.
Expand Down

0 comments on commit 33c35aa

Please sign in to comment.