diff options
| author | Luis Henriques <lhenriques@suse.com> | 2017-05-17 07:21:07 -0400 |
|---|---|---|
| committer | Ilya Dryomov <idryomov@gmail.com> | 2017-06-14 13:32:43 -0400 |
| commit | 03f219041fdbeb31cecff41bb1cb4e1018f9cf75 (patch) | |
| tree | 2c831e0e6149df0f676a419e8c90d1d5cd68dd41 | |
| parent | 32c1431eea4881a6b17bd7c639315010aeefa452 (diff) | |
ceph: check i_nlink while converting a file handle to dentry
Converting a file handle to a dentry can be done call after the inode
unlink. This means that __fh_to_dentry() requires an extra check to
verify the number of links is not 0.
The issue can be easily reproduced using xfstest generic/426, which does
something like:
name_to_handle_at(&fh)
echo 3 > /proc/sys/vm/drop_caches
unlink()
open_by_handle_at(&fh)
The call to open_by_handle_at() should fail, as the file doesn't exist
anymore.
Link: http://tracker.ceph.com/issues/19958
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| -rw-r--r-- | fs/ceph/export.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ceph/export.c b/fs/ceph/export.c index e8f11fa565c5..7df550c13d7f 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c | |||
| @@ -91,6 +91,10 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) | |||
| 91 | ceph_mdsc_put_request(req); | 91 | ceph_mdsc_put_request(req); |
| 92 | if (!inode) | 92 | if (!inode) |
| 93 | return ERR_PTR(-ESTALE); | 93 | return ERR_PTR(-ESTALE); |
| 94 | if (inode->i_nlink == 0) { | ||
| 95 | iput(inode); | ||
| 96 | return ERR_PTR(-ESTALE); | ||
| 97 | } | ||
| 94 | } | 98 | } |
| 95 | 99 | ||
| 96 | return d_obtain_alias(inode); | 100 | return d_obtain_alias(inode); |
