summaryrefslogtreecommitdiffstats
path: root/fs/ceph/dir.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-07-26 11:30:29 -0700
committerSage Weil <sage@newdream.net>2011-07-26 11:30:29 -0700
commit5f21c96dd5c615341963036ae8f5e4f5227a818d (patch)
tree898c5781623b68527427d201e3f975827d08935c /fs/ceph/dir.c
parent48d0cbd1242aac969560ef8b90f26ee3b09a6a5c (diff)
downloadop-kernel-dev-5f21c96dd5c615341963036ae8f5e4f5227a818d.zip
op-kernel-dev-5f21c96dd5c615341963036ae8f5e4f5227a818d.tar.gz
ceph: protect access to d_parent
d_parent is protected by d_lock: use it when looking up a dentry's parent directory inode. Also take a reference and drop it in the caller to avoid a use-after-free. Reported-by: Al Viro <viro@ZenIV.linux.org.uk> Reviewed-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/dir.c')
-rw-r--r--fs/ceph/dir.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 883c954..ed296ec 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -71,6 +71,21 @@ out_unlock:
return 0;
}
+struct inode *ceph_get_dentry_parent_inode(struct dentry *dentry)
+{
+ struct inode *inode = NULL;
+
+ if (!dentry)
+ return NULL;
+
+ spin_lock(&dentry->d_lock);
+ if (dentry->d_parent) {
+ inode = dentry->d_parent->d_inode;
+ ihold(inode);
+ }
+ spin_unlock(&dentry->d_lock);
+ return inode;
+}
/*
OpenPOWER on IntegriCloud