From a94ef56523a383c44c7a52e473e37a43fa0cb6a2 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 17 Jun 2016 11:58:13 +0800 Subject: [PATCH] mds: fix Session::check_access() It calls CInode::make_path_string(...) with the second argument is false. The second argument makes the third argument useless. For newly created inode, the path string is something like #1xxxxxxxxx. This can cause the access check to fail. Fixes: http://tracker.ceph.com/issues/16358 Signed-off-by: Yan, Zheng --- src/mds/CInode.cc | 11 ++++++++--- src/mds/CInode.h | 2 +- src/mds/SessionMap.cc | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index ea58d3831536d..0d97f88506723 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -807,9 +807,14 @@ bool CInode::is_projected_ancestor_of(CInode *other) return false; } -void CInode::make_path_string(string& s, bool force, CDentry *use_parent) const +/* + * If use_parent is NULL (it should be one of inode's projected parents), + * we use it to make path string. Otherwise, we use inode's parent dentry + * to make path string + */ +void CInode::make_path_string(string& s, CDentry *use_parent) const { - if (!force) + if (!use_parent) use_parent = parent; if (use_parent) { @@ -844,7 +849,7 @@ void CInode::make_path_string_projected(string& s) const p != projected_parent.end(); ++p) { string q; - make_path_string(q, true, *p); + make_path_string(q, *p); s += " "; s += q; } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 8f27bf0580bad..21686a2e080f9 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -738,7 +738,7 @@ public: // -- misc -- bool is_projected_ancestor_of(CInode *other); - void make_path_string(std::string& s, bool force=false, CDentry *use_parent=NULL) const; + void make_path_string(std::string& s, CDentry *use_parent=NULL) const; void make_path_string_projected(std::string& s) const; void make_path(filepath& s) const; void name_stray_dentry(std::string& dname); diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index eac0c5f4dd7c3..c9131b5f3e792 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -854,7 +854,7 @@ int Session::check_access(CInode *in, unsigned mask, path = in->get_projected_inode()->stray_prior_path; dout(20) << __func__ << " stray_prior_path " << path << dendl; } else { - in->make_path_string(path, false, in->get_projected_parent_dn()); + in->make_path_string(path, in->get_projected_parent_dn()); dout(20) << __func__ << " path " << path << dendl; } if (path.length()) -- 2.39.5