From: Tejun Heo <tj@kernel.org>
To: Li Zefan <lizefan@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>, cgroups <cgroups@vger.kernel.org>
Subject: Re: [PATCH v5 1/2] cgroup: fix cgroup_path() vs rename() race
Date: Mon, 4 Mar 2013 09:50:32 -0800 [thread overview]
Message-ID: <20130304175032.GD30413@htj.dyndns.org> (raw)
In-Reply-To: <51305264.2080602@huawei.com>
On Fri, Mar 01, 2013 at 03:01:56PM +0800, Li Zefan wrote:
> rename() will change dentry->d_name. The result of this race can
> be worse than seeing partially rewritten name, but we might access
> a stale pointer because rename() will re-allocate memory to hold
> a longer name.
>
> As accessing dentry->name must be protected by dentry->d_lock or
> parent inode's i_mutex, while on the other hand cgroup-path() can
> be called with some irq-safe spinlocks held, we can't generate
> cgroup path using dentry->d_name.
>
> Alternatively we make a copy of dentry->d_name and save it in
> cgrp->name when a cgroup is created, and update cgrp->name at
> rename().
>
> v5: use flexible array instead of zero-size array.
> v4: - allocate root_cgroup_name and all root_cgroup->name points to it.
> - add cgroup_name() wrapper.
> v3: use kfree_rcu() instead of synchronize_rcu() in user-visible path.
> v2: make cgrp->name RCU safe.
>
> Signed-off-by: Li Zefan <lizefan@huawei.com>
Applied 1-2 to cgroup/for-3.10.
Thanks.
--
tejun
prev parent reply other threads:[~2013-03-04 17:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-01 7:01 Li Zefan
2013-03-01 7:02 ` [PATCH 2/2] cpuset: use cgroup_name() in cpuset_print_task_mems_allowed() Li Zefan
2013-03-04 17:50 ` Tejun Heo [this message]
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=20130304175032.GD30413@htj.dyndns.org \
--to=tj@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.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®