Skip to content

Commit 33c35aa

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup: Prevent kill_css() from being called more than once
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 <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Cc: [email protected] # v4.5+
1 parent 2ea659a commit 33c35aa

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/linux/cgroup-defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum {
4848
CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
4949
CSS_RELEASED = (1 << 2), /* refcnt reached zero, released */
5050
CSS_VISIBLE = (1 << 3), /* css is visible to userland */
51+
CSS_DYING = (1 << 4), /* css is dying */
5152
};
5253

5354
/* bits in struct cgroup flags field */

kernel/cgroup/cgroup.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,6 +4265,11 @@ static void kill_css(struct cgroup_subsys_state *css)
42654265
{
42664266
lockdep_assert_held(&cgroup_mutex);
42674267

4268+
if (css->flags & CSS_DYING)
4269+
return;
4270+
4271+
css->flags |= CSS_DYING;
4272+
42684273
/*
42694274
* This must happen before css is disassociated with its cgroup.
42704275
* See seq_css() for details.

0 commit comments

Comments
 (0)