aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJing-Ting Wu <[email protected]>2022-08-23 13:41:46 +0800
committerTejun Heo <[email protected]>2022-08-23 08:11:06 -1000
commit763f4fb76e24959c370cdaa889b2492ba6175580 (patch)
tree541e52a6ef13de29f061d5a3a90eedabb4938e5f
parent4f7e7236435ca0abe005c674ebd6892c6e83aeb3 (diff)
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. Reported-by: Jing-Ting Wu <[email protected]> Suggested-by: Michal Koutný <[email protected]> Signed-off-by: Jing-Ting Wu <[email protected]> Tested-by: Jing-Ting Wu <[email protected]> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/T/ Acked-by: Mukesh Ojha <[email protected]> Fixes: a7df69b81aac ("cgroup: rstat: support cgroup1") Cc: [email protected] # v5.13+ Signed-off-by: Tejun Heo <[email protected]>
-rw-r--r--kernel/cgroup/cgroup.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index e1387499b336..e4bb5d57f4d1 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);
}