Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6553898rwb; Mon, 12 Dec 2022 03:33:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5BzrIYnfPeyM6zZppYreGDSb33d2hD8UX2qQRiempJBy+oH+Jic1TD5xl2JKciTRh6lOAn X-Received: by 2002:a05:6a20:d044:b0:a6:7b72:2a6a with SMTP id hv4-20020a056a20d04400b000a67b722a6amr19845317pzb.35.1670844821791; Mon, 12 Dec 2022 03:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670844821; cv=none; d=google.com; s=arc-20160816; b=fFM+HCq03Q8fZ3Mck2tbmQQuix4wuZ2RTEZKB59O6R6MQpb1HN+eQcEOUd7mV/S/JZ 3NkN+2W9Yv8Cqf1TGmooYtzYybUNOiyI/VkNcigx8Xr2OMulkM6MxmAHAvUjTuBLr2FZ VcxBZioDGbkFzuE6A5vnVEj2OALX3tb9VAPW0AYTzQ6Qp5IfZ5mjApfG0qExYY32atCG fkNiJue6aWfK6jyQET9Qbv1zKC9tIbhnpKbLU9uryH5OFM0/Cb5U5Pk5vgdndJYX39ck bH8WqrvQwW3m15+sTILIsnvLM5mOLgEltsRZXqLd2iKgfY3Avemck6McEu266BV+M2gL QcDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=XXB/aQ1KI3TUt8awhqzv0sGPGhdvap9bGuhaC5H6Qrc=; b=Ix0cKSN9O4zde1Yaw4zju+abAAWTAVRgGOf2nxVgrBC7M9xEPlo2xhRoN7hPNYq9eI ZialVstI58Y6eEBshuL5RX3bu28bfhMWvVH9YwrC+F5WIIn1faxXbgRJpGzSmeCPItnv MY2DnZfgXF96NDtC+NigOgdmyFXOiXlZw4Bs7rKhUqowSdyWVShvKrFLOpKnlce0z3xh 1M3OY3ArqOBI2SENdfIaVXciNpC3UJk17IxEXotQkUdul8S4P3WDPvB3jIV6uICFvZzT AzylyNL5A0PFYutAmQh8LkN32F6yevW2+nq0lH/6kG7Z/nkBdk2txkiJzAeTOOcZLE3o 7XzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HU4he0rj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v19-20020a634813000000b00476ca041d89si9022352pga.790.2022.12.12.03.33.26; Mon, 12 Dec 2022 03:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HU4he0rj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbiLLLXt (ORCPT + 99 others); Mon, 12 Dec 2022 06:23:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbiLLLX1 (ORCPT ); Mon, 12 Dec 2022 06:23:27 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3D6226C0 for ; Mon, 12 Dec 2022 03:22:49 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id fa4-20020a17090af0c400b002198d1328a0so13625902pjb.0 for ; Mon, 12 Dec 2022 03:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XXB/aQ1KI3TUt8awhqzv0sGPGhdvap9bGuhaC5H6Qrc=; b=HU4he0rjFXPYEWZKMENlB1iULduovU2bn3MJwO2HdFN2tGEuradCIB7rjHy91FPgJW jdMWDiyyA6jC1xpPcRf9VpqmfD7UG9X716ZCKqlStujzfYLubh+uiw5FxPrF1ianG6tK byt2aI3qyHafzPYnr8BPdJmXr7c8rBwfVUmWas8GOHM6AmAMevPeAJvFaarQzTDP1Ns1 /zaBk9G5YAa3HrqJAgINdyw65VdckJhsMfSdoY0z4jmVu2pLFpiUHAcTsUf7FwCQUcbh rFh/zyQyJ402yGn1s0dziOtvU5MgXMwIPaYjcHlJnMx4DAL3s/louuTVjDKAEECsNPi6 Hl4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XXB/aQ1KI3TUt8awhqzv0sGPGhdvap9bGuhaC5H6Qrc=; b=it+2/6cCrAexf9GC4fgkXDBYdo8UiBNKTmR+PS8Xh1xadp0DJxQ0ZJrBZA2s9y/mA9 WUIwGet4t1ZFWiBt6tSDTDFphb5OhNIbSILJN2ebToW3y0vFQDrZCj2sOJsqqecA7KO2 n0eD8Dfr5nPYJ9+lq+tmfz9qYRPFaJ5kgy04z4tmxbbFYlrrxvbWARMdyXjjQF+5hoM+ raLtLUupaU3bsmOQoQgyKvB9B6yKgrJRcnsv88g9Q80VZt/iBojgAMgZZaJmT7wqarga Qpj/k1NjtT7+xjksaK/YcVLgmbd/PoB/1i8Tnmf7x734jcPnVRfRMzTjdXfgEzV9dHDw VQWQ== X-Gm-Message-State: ANoB5pnB2PWS47lMeGZlR9yVj8K34hwfwHjTXp/QTHQcFVRO4bi8QUgn M3u1+1Y6FnTQW64S4aawmG5ZOrqcUOenmIFh+NA= X-Received: by 2002:a17:90a:d681:b0:213:d08f:a455 with SMTP id x1-20020a17090ad68100b00213d08fa455mr111906052pju.130.1670844169397; Mon, 12 Dec 2022 03:22:49 -0800 (PST) MIME-Version: 1.0 References: <1670786549-27041-1-git-send-email-dai.ngo@oracle.com> In-Reply-To: <1670786549-27041-1-git-send-email-dai.ngo@oracle.com> From: Xingyuan Mo Date: Mon, 12 Dec 2022 19:22:38 +0800 Message-ID: Subject: Re: [PATCH 1/1] NFSD: fix use-after-free in __nfs42_ssc_open() To: Dai Ngo Cc: chuck.lever@oracle.com, jlayton@kernel.org, kolga@netapp.com, linux-nfs@vger.kernel.org, security@kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Can I share the patch with the linux-distros list, so that distros can do their own testing and preparations? Regards, Xingyuan Mo On Mon, Dec 12, 2022 at 3:22 AM Dai Ngo wrote: > > Problem caused by source's vfsmount being unmounted but remains > on the delayed unmount list. This happens when nfs42_ssc_open() > return errors. > Fixed by removing nfsd4_interssc_connect(), leave the vfsmount > for the laundromat to unmount when idle time expires. > > Reported-by: Xingyuan Mo > Signed-off-by: Dai Ngo > --- > fs/nfsd/nfs4proc.c | 23 +++++++---------------- > 1 file changed, 7 insertions(+), 16 deletions(-) > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index 8beb2bc4c328..756e42cf0d01 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -1463,13 +1463,6 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp, > return status; > } > > -static void > -nfsd4_interssc_disconnect(struct vfsmount *ss_mnt) > -{ > - nfs_do_sb_deactive(ss_mnt->mnt_sb); > - mntput(ss_mnt); > -} > - > /* > * Verify COPY destination stateid. > * > @@ -1572,11 +1565,6 @@ nfsd4_cleanup_inter_ssc(struct vfsmount *ss_mnt, struct file *filp, > { > } > > -static void > -nfsd4_interssc_disconnect(struct vfsmount *ss_mnt) > -{ > -} > - > static struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, > struct nfs_fh *src_fh, > nfs4_stateid *stateid) > @@ -1762,7 +1750,8 @@ static int nfsd4_do_async_copy(void *data) > struct file *filp; > > filp = nfs42_ssc_open(copy->ss_mnt, ©->c_fh, > - ©->stateid); > + ©->stateid); > + > if (IS_ERR(filp)) { > switch (PTR_ERR(filp)) { > case -EBADF: > @@ -1771,7 +1760,7 @@ static int nfsd4_do_async_copy(void *data) > default: > nfserr = nfserr_offload_denied; > } > - nfsd4_interssc_disconnect(copy->ss_mnt); > + /* ss_mnt will be unmounted by the laundromat */ > goto do_callback; > } > nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file, > @@ -1852,8 +1841,10 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, > if (async_copy) > cleanup_async_copy(async_copy); > status = nfserrno(-ENOMEM); > - if (nfsd4_ssc_is_inter(copy)) > - nfsd4_interssc_disconnect(copy->ss_mnt); > + /* > + * source's vfsmount of inter-copy will be unmounted > + * by the laundromat > + */ > goto out; > } > > -- > 2.9.5 >