Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org # v4.5+

authored by

Waiman Long and committed by
Tejun Heo
33c35aa4 2ea659a9

+6
+1
include/linux/cgroup-defs.h
··· 48 48 CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */ 49 49 CSS_RELEASED = (1 << 2), /* refcnt reached zero, released */ 50 50 CSS_VISIBLE = (1 << 3), /* css is visible to userland */ 51 + CSS_DYING = (1 << 4), /* css is dying */ 51 52 }; 52 53 53 54 /* bits in struct cgroup flags field */
+5
kernel/cgroup/cgroup.c
··· 4265 4265 { 4266 4266 lockdep_assert_held(&cgroup_mutex); 4267 4267 4268 + if (css->flags & CSS_DYING) 4269 + return; 4270 + 4271 + css->flags |= CSS_DYING; 4272 + 4268 4273 /* 4269 4274 * This must happen before css is disassociated with its cgroup. 4270 4275 * See seq_css() for details.