summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup/cgroup.c
diff options
context:
space:
mode:
authorElena Reshetova <elena.reshetova@intel.com>2017-03-08 03:00:40 -0500
committerTejun Heo <tj@kernel.org>2017-03-08 17:46:03 -0500
commit4b9502e63b5e2b1b5ef491919d3219b9440fe0b3 (patch)
tree75ede84d703f3e230322be6f11b87625ba9ab72f /kernel/cgroup/cgroup.c
parent387ad9674b0013c8756ad20d854ff005b0c313ad (diff)
kernel: convert css_set.refcount from atomic_t to refcount_t
refcount_t type and corresponding API should be used instead of atomic_t when the variable is used as a reference counter. This allows to avoid accidental refcounter overflows that might lead to use-after-free situations. Signed-off-by: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: David Windsor <dwindsor@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup/cgroup.c')
-rw-r--r--kernel/cgroup/cgroup.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 8ee78688e36d..b1cc1c306668 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -554,7 +554,7 @@ EXPORT_SYMBOL_GPL(of_css);
554 * haven't been created. 554 * haven't been created.
555 */ 555 */
556struct css_set init_css_set = { 556struct css_set init_css_set = {
557 .refcount = ATOMIC_INIT(1), 557 .refcount = REFCOUNT_INIT(1),
558 .tasks = LIST_HEAD_INIT(init_css_set.tasks), 558 .tasks = LIST_HEAD_INIT(init_css_set.tasks),
559 .mg_tasks = LIST_HEAD_INIT(init_css_set.mg_tasks), 559 .mg_tasks = LIST_HEAD_INIT(init_css_set.mg_tasks),
560 .task_iters = LIST_HEAD_INIT(init_css_set.task_iters), 560 .task_iters = LIST_HEAD_INIT(init_css_set.task_iters),
@@ -724,7 +724,7 @@ void put_css_set_locked(struct css_set *cset)
724 724
725 lockdep_assert_held(&css_set_lock); 725 lockdep_assert_held(&css_set_lock);
726 726
727 if (!atomic_dec_and_test(&cset->refcount)) 727 if (!refcount_dec_and_test(&cset->refcount))
728 return; 728 return;
729 729
730 /* This css_set is dead. unlink it and release cgroup and css refs */ 730 /* This css_set is dead. unlink it and release cgroup and css refs */
@@ -977,7 +977,7 @@ static struct css_set *find_css_set(struct css_set *old_cset,
977 return NULL; 977 return NULL;
978 } 978 }
979 979
980 atomic_set(&cset->refcount, 1); 980 refcount_set(&cset->refcount, 1);
981 INIT_LIST_HEAD(&cset->tasks); 981 INIT_LIST_HEAD(&cset->tasks);
982 INIT_LIST_HEAD(&cset->mg_tasks); 982 INIT_LIST_HEAD(&cset->mg_tasks);
983 INIT_LIST_HEAD(&cset->task_iters); 983 INIT_LIST_HEAD(&cset->task_iters);