Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dff4c8bb authored by Waiman Long's avatar Waiman Long Committed by Greg Kroah-Hartman
Browse files

cgroup: Prevent kill_css() from being called more than once



commit 33c35aa4817864e056fd772230b0c6b552e36ea2 upstream.

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: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b59ec707
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ enum {
	CSS_ONLINE	= (1 << 1), /* between ->css_online() and ->css_offline() */
	CSS_ONLINE	= (1 << 1), /* between ->css_online() and ->css_offline() */
	CSS_RELEASED	= (1 << 2), /* refcnt reached zero, released */
	CSS_RELEASED	= (1 << 2), /* refcnt reached zero, released */
	CSS_VISIBLE	= (1 << 3), /* css is visible to userland */
	CSS_VISIBLE	= (1 << 3), /* css is visible to userland */
	CSS_DYING	= (1 << 4), /* css is dying */
};
};


/* bits in struct cgroup flags field */
/* bits in struct cgroup flags field */
+5 −0
Original line number Original line Diff line number Diff line
@@ -5407,6 +5407,11 @@ static void kill_css(struct cgroup_subsys_state *css)
{
{
	lockdep_assert_held(&cgroup_mutex);
	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.
	 * This must happen before css is disassociated with its cgroup.
	 * See seq_css() for details.
	 * See seq_css() for details.