From: Al Viro <viro@ZenIV.linux.org.uk>
To: Li Zefan <lizefan@huawei.com>
Cc: Tejun Heo <tj@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Cgroups <cgroups@vger.kernel.org>,
Sasha Levin <levinsasha928@gmail.com>
Subject: Re: [PATCH 2/2] cgroup: fix cgroup_path() vs rename() race, take 2
Date: Sun, 17 Feb 2013 06:48:52 +0000 [thread overview]
Message-ID: <20130217064852.GD4503@ZenIV.linux.org.uk> (raw)
In-Reply-To: <51205699.5080900@huawei.com>
On Sun, Feb 17, 2013 at 12:03:37PM +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_lock and save it in
> cgrp->name when a cgroup is created, and update cgrp->name at
> rename().
Yecchhh... This is just plain wrong. If nothing else, your locking
is way too heavy for your uses. Just put freeing those separately
allocated names in RCU callback and assign them on rename with
rcu_assign_pointer(). Then put cgroup_path() under rcu_read_lock()
(most of the callers already are) and be done with that.
next prev parent reply other threads:[~2013-02-17 6:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-17 4:03 [PATCH 1/2] Revert "cgroup: fix cgroup_path() vs rename() race" Li Zefan
2013-02-17 4:03 ` [PATCH 2/2] cgroup: fix cgroup_path() vs rename() race, take 2 Li Zefan
2013-02-17 6:48 ` Al Viro [this message]
2013-02-18 17:07 ` [PATCH 1/2] Revert "cgroup: fix cgroup_path() vs rename() race" 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=20130217064852.GD4503@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=cgroups@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=tj@kernel.org \
/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