Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1643274 > unrolled thread

[PATCH] ceph: check i_nlink while converting a file handle to dentry

Started byLuis Henriques <lhenriques@suse.com>
First post2017-05-17 13:30 +0200
Last post2017-05-19 02:50 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ceph: check i_nlink while converting a file handle to dentry Luis Henriques <lhenriques@suse.com> - 2017-05-17 13:30 +0200
    Re: [PATCH] ceph: check i_nlink while converting a file handle to  dentry "Yan, Zheng" <zyan@redhat.com> - 2017-05-18 15:40 +0200
      Re: [PATCH] ceph: check i_nlink while converting a file handle to  dentry Luis Henriques <lhenriques@suse.com> - 2017-05-18 18:50 +0200
        Re: [PATCH] ceph: check i_nlink while converting a file handle to  dentry "Yan, Zheng" <zyan@redhat.com> - 2017-05-19 02:50 +0200

#1643274 — [PATCH] ceph: check i_nlink while converting a file handle to dentry

FromLuis Henriques <lhenriques@suse.com>
Date2017-05-17 13:30 +0200
Subject[PATCH] ceph: check i_nlink while converting a file handle to dentry
Message-ID<tI5js-2pQ-7@gated-at.bofh.it>
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.

Cc: stable@vger.kernel.org
Link: http://tracker.ceph.com/issues/19958
Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
 fs/ceph/export.c | 4 ++++
 1 file changed, 4 insertions(+)

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)
 		ceph_mdsc_put_request(req);
 		if (!inode)
 			return ERR_PTR(-ESTALE);
+		if (inode->i_nlink == 0) {
+			iput(inode);
+			return ERR_PTR(-ESTALE);
+		}
 	}
 
 	return d_obtain_alias(inode);

[toc] | [next] | [standalone]


#1644545 — Re: [PATCH] ceph: check i_nlink while converting a file handle to dentry

From"Yan, Zheng" <zyan@redhat.com>
Date2017-05-18 15:40 +0200
SubjectRe: [PATCH] ceph: check i_nlink while converting a file handle to dentry
Message-ID<tItOO-3bL-35@gated-at.bofh.it>
In reply to#1643274
> On 17 May 2017, at 19:21, Luis Henriques <lhenriques@suse.com> wrote:
> 
> 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.
> 
> Cc: stable@vger.kernel.org
> Link: http://tracker.ceph.com/issues/19958
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
> fs/ceph/export.c | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> 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)
> 		ceph_mdsc_put_request(req);
> 		if (!inode)
> 			return ERR_PTR(-ESTALE);
> +		if (inode->i_nlink == 0) {
> +			iput(inode);
> +			return ERR_PTR(-ESTALE);
> +		}
> 	}

maybe we should do this check in MDS

Regards
Yan, Zheng

> 
> 	return d_obtain_alias(inode);

[toc] | [prev] | [next] | [standalone]


#1644750 — Re: [PATCH] ceph: check i_nlink while converting a file handle to dentry

FromLuis Henriques <lhenriques@suse.com>
Date2017-05-18 18:50 +0200
SubjectRe: [PATCH] ceph: check i_nlink while converting a file handle to dentry
Message-ID<tIwMH-5iy-33@gated-at.bofh.it>
In reply to#1644545
On Thu, May 18, 2017 at 09:36:44PM +0800, Yan, Zheng wrote:
> 
> > On 17 May 2017, at 19:21, Luis Henriques <lhenriques@suse.com> wrote:
> > 
> > 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.
> > 
> > Cc: stable@vger.kernel.org
> > Link: http://tracker.ceph.com/issues/19958
> > Signed-off-by: Luis Henriques <lhenriques@suse.com>
> > ---
> > fs/ceph/export.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> > 
> > 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)
> > 		ceph_mdsc_put_request(req);
> > 		if (!inode)
> > 			return ERR_PTR(-ESTALE);
> > +		if (inode->i_nlink == 0) {
> > +			iput(inode);
> > +			return ERR_PTR(-ESTALE);
> > +		}
> > 	}
> 
> maybe we should do this check in MDS

Thank you for your review.  Are you suggesting to do this check *only* in
the MDS?  I guess that's probably a good thing to do too, but don't you
think it's a good idea to keep it on the client side as well?

Cheers,
--
Luís

[toc] | [prev] | [next] | [standalone]


#1644976 — Re: [PATCH] ceph: check i_nlink while converting a file handle to dentry

From"Yan, Zheng" <zyan@redhat.com>
Date2017-05-19 02:50 +0200
SubjectRe: [PATCH] ceph: check i_nlink while converting a file handle to dentry
Message-ID<tIEhc-2EL-15@gated-at.bofh.it>
In reply to#1644750
> On 19 May 2017, at 00:48, Luis Henriques <lhenriques@suse.com> wrote:
> 
> On Thu, May 18, 2017 at 09:36:44PM +0800, Yan, Zheng wrote:
>> 
>>> On 17 May 2017, at 19:21, Luis Henriques <lhenriques@suse.com> wrote:
>>> 
>>> 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.
>>> 
>>> Cc: stable@vger.kernel.org
>>> Link: http://tracker.ceph.com/issues/19958
>>> Signed-off-by: Luis Henriques <lhenriques@suse.com>
>>> ---
>>> fs/ceph/export.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>> 
>>> 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)
>>> 		ceph_mdsc_put_request(req);
>>> 		if (!inode)
>>> 			return ERR_PTR(-ESTALE);
>>> +		if (inode->i_nlink == 0) {
>>> +			iput(inode);
>>> +			return ERR_PTR(-ESTALE);
>>> +		}
>>> 	}
>> 
>> maybe we should do this check in MDS
> 
> Thank you for your review.  Are you suggesting to do this check *only* in
> the MDS?  I guess that's probably a good thing to do too, but don't you
> think it's a good idea to keep it on the client side as well?

Applied. Thanks

Yan, Zheng

> 
> Cheers,
> --
> Luís

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web