diff options
author | Jeff Layton <jlayton@kernel.org> | 2019-04-17 12:58:28 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-02 09:58:54 +0200 |
commit | 246d2bf32da1df979b2bb0b4ca38b9b2b6ac2bf4 (patch) | |
tree | ccf6e4bfec3c3530fc8ca0a310c101b24dc7226e | |
parent | 8d693ef0141c90dd94fe47be1727214bf3adb3dd (diff) | |
download | linux-stable-246d2bf32da1df979b2bb0b4ca38b9b2b6ac2bf4.tar.gz linux-stable-246d2bf32da1df979b2bb0b4ca38b9b2b6ac2bf4.tar.bz2 linux-stable-246d2bf32da1df979b2bb0b4ca38b9b2b6ac2bf4.zip |
ceph: ensure d_name stability in ceph_dentry_hash()
commit 76a495d666e5043ffc315695f8241f5e94a98849 upstream.
Take the d_lock here to ensure that d_name doesn't change.
Cc: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/ceph/dir.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 82928cea0209..7f3f64ba464f 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1470,6 +1470,7 @@ void ceph_dentry_lru_del(struct dentry *dn) unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) { struct ceph_inode_info *dci = ceph_inode(dir); + unsigned hash; switch (dci->i_dir_layout.dl_dir_hash) { case 0: /* for backward compat */ @@ -1477,8 +1478,11 @@ unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) return dn->d_name.hash; default: - return ceph_str_hash(dci->i_dir_layout.dl_dir_hash, + spin_lock(&dn->d_lock); + hash = ceph_str_hash(dci->i_dir_layout.dl_dir_hash, dn->d_name.name, dn->d_name.len); + spin_unlock(&dn->d_lock); + return hash; } } |