ceph: close race between d_name_cmp() and update_dentry_lease()
authorYan, Zheng <zyan@redhat.com>
Wed, 22 May 2019 13:49:44 +0000 (21:49 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 8 Jul 2019 12:01:42 +0000 (14:01 +0200)
commit543212b3a4a4abe0cbc610c704cc3cb85315c367
treed0f08eb9510816bdb6de5d9a6c65120330d8c80a
parent749607731e26dfb2558118038c40e9c0c80d23b5
ceph: close race between d_name_cmp() and update_dentry_lease()

d_name_cmp() and update_dentry_lease() lock and unlock dentry->d_lock
respectively. Dentry may get renamed between them. The fix is moving
the dentry name compare into update_dentry_lease().

This patch introduce two version of update_dentry_lease(). One version
is for the case that parent inode is locked. It does not need to check
parent/target inode and dentry name. Another version is for the case
that parent inode is not locked. It checks parent/target inode and
dentry name after locking dentry->d_lock.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/inode.c