From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15DDBC433E0 for ; Sat, 20 Feb 2021 03:21:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFD2964EDE for ; Sat, 20 Feb 2021 03:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbhBTDVj (ORCPT ); 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 > >>>