mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jing-Ting Wu <Jing-Ting.Wu@mediatek.com>
To: "Michal Koutný" <mkoutny@suse.com>, "Tejun Heo" <tj@kernel.org>,
	"Zefan Li" <lizefan.x@bytedance.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>
Cc: <Jonathan.JMChen@mediatek.com>, <Lixiong.Liu@mediatek.com>,
	<wsd_upstream@mediatek.com>, <Wenju.Xu@mediatek.com>,
	Jing-Ting Wu <Jing-Ting.Wu@mediatek.com>,
	<cgroups@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: [PATCH 1/1] cgroup: Fix race condition at rebind_subsystems()
Date: Tue, 23 Aug 2022 13:09:41 +0800	[thread overview]
Message-ID: <20220823050943.28619-1-Jing-Ting.Wu@mediatek.com> (raw)

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@suse.com>
Signed-off-by: Jing-Ting Wu <Jing-Ting.Wu@mediatek.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


             reply	other threads:[~2022-08-23  5:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23  5:09 Jing-Ting Wu [this message]
2022-08-23  5:41 Jing-Ting Wu
2022-08-23  7:33 ` Mukesh Ojha
2022-08-23 18:12 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220823050943.28619-1-Jing-Ting.Wu@mediatek.com \
    --to=jing-ting.wu@mediatek.com \
    --cc=Jonathan.JMChen@mediatek.com \
    --cc=Lixiong.Liu@mediatek.com \
    --cc=Wenju.Xu@mediatek.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lizefan.x@bytedance.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mkoutny@suse.com \
    --cc=tj@kernel.org \
    --cc=wsd_upstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®