mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cgroup/cpuset: update parent subparts cpumask while holding css refcnt
@ 2023-07-01  6:50 Miaohe Lin
  2023-07-01 23:38 ` Waiman Long
  2023-07-10 15:11 ` Michal Koutný
  0 siblings, 2 replies; 11+ messages in thread
From: Miaohe Lin @ 2023-07-01  6:50 UTC (permalink / raw)
  To: longman, tj, hannes, lizefan.x; +Cc: cgroups, linux-kernel, linmiaohe

update_parent_subparts_cpumask() is called outside RCU read-side critical
section without holding extra css refcnt of cp. In theroy, cp could be
freed at any time. Holding extra css refcnt to ensure cp is valid while
updating parent subparts cpumask.

Fixes: d7c8142d5a55 ("cgroup/cpuset: Make partition invalid if cpumask change violates exclusivity rule")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 kernel/cgroup/cpuset.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 58e6f18f01c1..632a9986d5de 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1806,9 +1806,12 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 		cpuset_for_each_child(cp, css, parent)
 			if (is_partition_valid(cp) &&
 			    cpumask_intersects(trialcs->cpus_allowed, cp->cpus_allowed)) {
+				if (!css_tryget_online(&cp->css))
+					continue;
 				rcu_read_unlock();
 				update_parent_subparts_cpumask(cp, partcmd_invalidate, NULL, &tmp);
 				rcu_read_lock();
+				css_put(&cp->css);
 			}
 		rcu_read_unlock();
 		retval = 0;
-- 
2.33.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-12  1:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-01  6:50 [PATCH] cgroup/cpuset: update parent subparts cpumask while holding css refcnt Miaohe Lin
2023-07-01 23:38 ` Waiman Long
2023-07-01 23:46   ` Waiman Long
2023-07-03  2:58     ` Miaohe Lin
2023-07-03 19:18       ` Tejun Heo
2023-07-10 15:11 ` Michal Koutný
2023-07-10 15:40   ` Waiman Long
2023-07-10 15:51     ` Michal Koutný
2023-07-11  2:52     ` Miaohe Lin
2023-07-11 11:52       ` Michal Koutný
2023-07-12  1:56         ` Miaohe Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®