1 From 76a495d666e5043ffc315695f8241f5e94a98849 Mon Sep 17 00:00:00 2001
2 From: Jeff Layton <jlayton@kernel.org>
3 Date: Wed, 17 Apr 2019 12:58:28 -0400
4 Subject: ceph: ensure d_name stability in ceph_dentry_hash()
6 From: Jeff Layton <jlayton@kernel.org>
8 commit 76a495d666e5043ffc315695f8241f5e94a98849 upstream.
10 Take the d_lock here to ensure that d_name doesn't change.
12 Cc: stable@vger.kernel.org
13 Signed-off-by: Jeff Layton <jlayton@kernel.org>
14 Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
15 Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 fs/ceph/dir.c | 6 +++++-
20 1 file changed, 5 insertions(+), 1 deletion(-)
24 @@ -1288,6 +1288,7 @@ void ceph_dentry_lru_del(struct dentry *
25 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn)
27 struct ceph_inode_info *dci = ceph_inode(dir);
30 switch (dci->i_dir_layout.dl_dir_hash) {
31 case 0: /* for backward compat */
32 @@ -1295,8 +1296,11 @@ unsigned ceph_dentry_hash(struct inode *
33 return dn->d_name.hash;
36 - return ceph_str_hash(dci->i_dir_layout.dl_dir_hash,
37 + spin_lock(&dn->d_lock);
38 + hash = ceph_str_hash(dci->i_dir_layout.dl_dir_hash,
39 dn->d_name.name, dn->d_name.len);
40 + spin_unlock(&dn->d_lock);