Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1641693
| From | Waiman Long <longman@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH v2 07/17] cgroup: Prevent kill_css() from being called more than once |
| Date | 2017-05-15 15:40 +0200 |
| Message-ID | <tHoob-lZ-51@gated-at.bofh.it> (permalink) |
| References | <tHoo9-lZ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
include/linux/cgroup-defs.h | 1 +
kernel/cgroup/cgroup.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index e8d0cfc..b123afc 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -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 */
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index f14deca..7b085d5 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4630,6 +4630,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.
--
1.8.3.1
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[RFC PATCH v2 07/17] cgroup: Prevent kill_css() from being called more than once Waiman Long <longman@redhat.com> - 2017-05-15 15:40 +0200
Re: [RFC PATCH v2 07/17] cgroup: Prevent kill_css() from being called more than once Tejun Heo <tj@kernel.org> - 2017-05-17 21:30 +0200
Re: [RFC PATCH v2 07/17] cgroup: Prevent kill_css() from being called more than once Waiman Long <longman@redhat.com> - 2017-05-17 22:30 +0200
Re: [RFC PATCH v2 07/17] cgroup: Prevent kill_css() from being called more than once Tejun Heo <tj@kernel.org> - 2017-05-17 23:40 +0200
csiph-web