From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbdESAl4 convert rfc822-to-8bit (ORCPT ); Thu, 18 May 2017 20:41:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54604 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751130AbdESAlx (ORCPT ); Thu, 18 May 2017 20:41:53 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 666684E040 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=zyan@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 666684E040 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] ceph: check i_nlink while converting a file handle to dentry From: "Yan, Zheng" In-Reply-To: <20170518164805.jgvxvvvseurrur7e@hermes.olymp> Date: Fri, 19 May 2017 08:41:45 +0800 Cc: Sage Weil , Ilya Dryomov , ceph-devel , Linux Kernel Mailing List Content-Transfer-Encoding: 8BIT Message-Id: References: <20170517112107.31025-1-lhenriques@suse.com> <20170518164805.jgvxvvvseurrur7e@hermes.olymp> To: Luis Henriques X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 19 May 2017 00:41:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 19 May 2017, at 00:48, Luis Henriques wrote: > > On Thu, May 18, 2017 at 09:36:44PM +0800, Yan, Zheng wrote: >> >>> On 17 May 2017, at 19:21, Luis Henriques 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 >>> --- >>> 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