[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220823050943.28619-1-Jing-Ting.Wu@mediatek.com>
Date: Tue, 23 Aug 2022 13:09:41 +0800
From: Jing-Ting Wu <Jing-Ting.Wu@...iatek.com>
To: Michal Koutný <mkoutny@...e.com>,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
Matthias Brugger <matthias.bgg@...il.com>
CC: <Jonathan.JMChen@...iatek.com>, <Lixiong.Liu@...iatek.com>,
<wsd_upstream@...iatek.com>, <Wenju.Xu@...iatek.com>,
Jing-Ting Wu <Jing-Ting.Wu@...iatek.com>,
<cgroups@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>
Subject: [PATCH 1/1] cgroup: Fix race condition at rebind_subsystems()
Root cause:
The rebind_subsystems() is no lock held when move css object from A
list to B list,then let B's head be treated as css node at
list_for_each_entry_rcu().
Solution:
Add grace period before invalidating the removed rstat_css_node.
Suggested-by: Michal Koutný <mkoutny@...e.com>
Signed-off-by: Jing-Ting Wu <Jing-Ting.Wu@...iatek.com>
---
kernel/cgroup/cgroup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index ffaccd6373f1..0d0c959966ed 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1820,6 +1820,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
if (ss->css_rstat_flush) {
list_del_rcu(&css->rstat_css_node);
+ synchronize_rcu();
list_add_rcu(&css->rstat_css_node,
&dcgrp->rstat_css_list);
}
--
2.18.0
Powered by blists - more mailing lists