Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp92513pxb; Fri, 19 Feb 2021 19:22:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBqstMjPkat+5rri32b5GDxbWB1x17nveGMttdr6KokEHJET3olP7KtyYyaAhRIdfgT2AX X-Received: by 2002:a05:6402:b03:: with SMTP id bm3mr1191909edb.13.1613791365990; Fri, 19 Feb 2021 19:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613791365; cv=none; d=google.com; s=arc-20160816; b=YD3fIQ+/Ugv0nG3lTqDSmOWuuoBtmDEVAiQ52+8562+w/C921V3msBn2eXLAq9oOJN +LhLSfWRun5uRUMIP5hhDRikOghZH0f692W6VG+jfF/oQxzljenAb5CsvbV3egnr7M/x F4frKMuBGQhA9kAz+Kfz5dZtTOLMFYhAUXUejXrtZpZNR8w4qdzYw1Nzy/S4evCDG4KW mYH8E9i95o/NjorBWR6lvePdhFWh+lwF/MYLw+ALw7q4/YTF/kIZeKCyUUKWVfh3uJb/ /Id6+szS3bPIx5JharvnDozec3szp1S82YABn3tNvkGHAU4Qx7NAN1yRgkmge3wkX/Lt fgIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=83GLWIXRVzuk5qgOs31MrJyw5mWag/iG2ysEVUJq+dM=; b=pyjO9hYs+2HMVxtGwI1qh3KcDQAPTkBnWrEoyJkJf/mUornDFu6ZPFl6oK0rvaz6v5 Qvd7zYJzCKc3Akcg0S/IXhVOKxuPKkR2HcpN0/jVYNSdlxVk+U+UqSGZiqvH7j6uAeHX BjBKSVfom830RN05RGRwgZNTghGSyR2G3913JcWeNh0bNB0w4nzIKdooztVvgILNFD7U kZWmQuInzCCT91rf1MXMIODSTPiaU6V0naGj79LG2DguVlExsBPwl7c17XAZUKuEsEky 7FpmhEhOL4MOohyKuDbCyvL7bx+rQ1B4ubxAUH69Ca75Cu49RB7fBw8IEUnLluBdiKIC tXaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=UWtq53K1; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si7025563edt.86.2021.02.19.19.22.14; Fri, 19 Feb 2021 19:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=UWtq53K1; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbhBTDVj (ORCPT + 99 others); Fri, 19 Feb 2021 22:21:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbhBTDVi (ORCPT ); Fri, 19 Feb 2021 22:21:38 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E16AC061574 for ; Fri, 19 Feb 2021 19:20:58 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 3791328E5; Fri, 19 Feb 2021 22:20:57 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 3791328E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1613791257; bh=83GLWIXRVzuk5qgOs31MrJyw5mWag/iG2ysEVUJq+dM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UWtq53K1DU/9kB9Ny5QIxTTJaHRjDVbVuCY/j0Wxcj8sJ7GlG1L39Izy5+4bEeePN lBqbatLOk7or6/90TyCq2pkbQtDh/tubAogJuWhrJt+hM2f/uIWwdrbcAlMFuPCAcp nf+Nvc26fy4fsaHwc6F55Q+F1bvBA7r92kDVnw1w= Date: Fri, 19 Feb 2021 22:20:57 -0500 From: "J. Bruce Fields" To: dai.ngo@oracle.com Cc: Olga Kornievskaia , linux-nfs Subject: Re: [PATCH 1/2] NFSD: Fix use-after-free warning when doing inter-server copy Message-ID: <20210220032057.GA25183@fieldses.org> References: <20201029190716.70481-1-dai.ngo@oracle.com> <20201029190716.70481-2-dai.ngo@oracle.com> <20210220010903.GE5357@fieldses.org> <69ea46ff-80d1-acfa-22a5-3d1b6230728f@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <69ea46ff-80d1-acfa-22a5-3d1b6230728f@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Feb 19, 2021 at 05:31:58PM -0800, dai.ngo@oracle.com wrote: > If this is the cause why we don't drop the mount after the copy > then I can restore the patch and look into this problem. Unfortunately, > all my test machines are down for maintenance until Sunday/Monday. I think we can take some time to figure out what's actually going on here before reverting anything. --b. > > -Dai > > On 2/19/21 5:09 PM, J. Bruce Fields wrote: > >Dai, do you have a copy of the original use-after-free warning? > > > >--b. > > > >On Fri, Feb 19, 2021 at 07:18:53PM -0500, Olga Kornievskaia wrote: > >>Hi Dai (Bruce), > >> > >>This patch is what broke the mount that's now left behind between the > >>source server and the destination server. We are no longer dropping > >>the necessary reference on the mount to go away. I haven't been paying > >>as much attention as I should have been to the changes. The original > >>code called fput(src) so a simple refcount of the file. Then things > >>got complicated and moved to nfsd_file_put(). So I don't understand > >>complexity. But we need to do some kind of put to decrement the needed > >>reference on the superblock. Bruce any ideas? Can we go back to > >>fput()? > >> > >>On Thu, Oct 29, 2020 at 3:08 PM Dai Ngo wrote: > >>>The source file nfsd_file is not constructed the same as other > >>>nfsd_file's via nfsd_file_alloc. nfsd_file_put should not be > >>>called to free the object; nfsd_file_put is not the inverse of > >>>kzalloc, instead kfree is called by nfsd4_do_async_copy when done. > >>> > >>>Fixes: ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy") > >>>Signed-off-by: Dai Ngo > >>>--- > >>> fs/nfsd/nfs4proc.c | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>>diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > >>>index ad2fa1a8e7ad..9c43cad7e408 100644 > >>>--- a/fs/nfsd/nfs4proc.c > >>>+++ b/fs/nfsd/nfs4proc.c > >>>@@ -1299,7 +1299,7 @@ nfsd4_cleanup_inter_ssc(struct vfsmount *ss_mnt, struct nfsd_file *src, > >>> struct nfsd_file *dst) > >>> { > >>> nfs42_ssc_close(src->nf_file); > >>>- nfsd_file_put(src); > >>>+ /* 'src' is freed by nfsd4_do_async_copy */ > >>> nfsd_file_put(dst); > >>> mntput(ss_mnt); > >>> } > >>>-- > >>>2.20.1.1226.g1595ea5.dirty > >>>