Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1425306

[PATCH 1/3] cgroup: fix idr leak for the first cgroup root

From Johannes Weiner <hannes@cmpxchg.org>
Newsgroups linux.kernel
Subject [PATCH 1/3] cgroup: fix idr leak for the first cgroup root
Date 2016-06-17 18:30 +0200
Message-ID <rL4OB-qf-7@gated-at.bofh.it> (permalink)
References <rKwtz-36W-9@gated-at.bofh.it> <rKLLX-4lm-5@gated-at.bofh.it> <rL4OB-qf-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The valid cgroup hierarchy ID range includes 0, so we can't filter for
positive numbers when freeing it, or it'll leak the first ID. No big
deal, just disruptive when reading the code.

The ID is freed during error handling and when the reference count
hits zero, so the double-free test is not necessary; remove it.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 kernel/cgroup.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 86cb5c6e8932..36fc0ff506c3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1158,18 +1158,12 @@ static void cgroup_exit_root_id(struct cgroup_root *root)
 {
 	lockdep_assert_held(&cgroup_mutex);
 
-	if (root->hierarchy_id) {
-		idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
-		root->hierarchy_id = 0;
-	}
+	idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
 }
 
 static void cgroup_free_root(struct cgroup_root *root)
 {
 	if (root) {
-		/* hierarchy ID should already have been released */
-		WARN_ON_ONCE(root->hierarchy_id);
-
 		idr_destroy(&root->cgroup_idr);
 		kfree(root);
 	}
-- 
2.8.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm: memcontrol: fix cgroup creation failure after many small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-06-16 05:50 +0200
  Re: [PATCH] mm: memcontrol: fix cgroup creation failure after many  small jobs Tejun Heo <tj@kernel.org> - 2016-06-16 22:10 +0200
    [PATCH 3/3] mm: memcontrol: fix cgroup creation failure after many  small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-06-17 18:30 +0200
      Re: [PATCH 3/3] mm: memcontrol: fix cgroup creation failure after  many small jobs Tejun Heo <tj@kernel.org> - 2016-06-17 20:20 +0200
      Re: [PATCH 3/3] mm: memcontrol: fix cgroup creation failure after  many small jobs Nikolay Borisov <kernel@kyup.com> - 2016-06-20 08:20 +0200
      Re: [PATCH 3/3] mm: memcontrol: fix cgroup creation failure after  many small jobs Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-06-21 12:40 +0200
        Re: [PATCH 3/3] mm: memcontrol: fix cgroup creation failure after  many small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-06-21 17:50 +0200
    [PATCH 1/3] cgroup: fix idr leak for the first cgroup root Johannes Weiner <hannes@cmpxchg.org> - 2016-06-17 18:30 +0200
    [PATCH 2/3] cgroup: remove unnecessary 0 check from css_from_id() Johannes Weiner <hannes@cmpxchg.org> - 2016-06-17 18:30 +0200
      Re: [PATCH 2/3] cgroup: remove unnecessary 0 check from css_from_id() Tejun Heo <tj@kernel.org> - 2016-06-17 20:20 +0200
    Re: [PATCH] mm: memcontrol: fix cgroup creation failure after many  small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-06-17 18:30 +0200
  Re: [PATCH] mm: memcontrol: fix cgroup creation failure after many  small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-06-17 18:50 +0200

csiph-web