diff options
author | Li Zefan <lizefan@huawei.com> | 2013-03-01 02:01:56 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-03-04 12:50:08 -0500 |
commit | 65dff759d2948cf18e2029fc5c0c595b8b7da3a5 (patch) | |
tree | 2904e81e44bb939413f406bbb2056e88df008f72 /block/blk-cgroup.h | |
parent | 6dbe51c251a327e012439c4772097a13df43c5b8 (diff) |
cgroup: fix cgroup_path() vs rename() race
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>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r-- | block/blk-cgroup.h | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index f2b292925ccd..4e595ee8c915 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
@@ -247,9 +247,7 @@ static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen) | |||
247 | { | 247 | { |
248 | int ret; | 248 | int ret; |
249 | 249 | ||
250 | rcu_read_lock(); | ||
251 | ret = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen); | 250 | ret = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen); |
252 | rcu_read_unlock(); | ||
253 | if (ret) | 251 | if (ret) |
254 | strncpy(buf, "<unavailable>", buflen); | 252 | strncpy(buf, "<unavailable>", buflen); |
255 | return ret; | 253 | return ret; |