Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4937551pxb; Tue, 28 Sep 2021 07:17:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4mGhzvNKv6s5N8LsWswAGt029HpvIN4v/ur8p6PXhtMT3kRCBxgpRQWCVYwmjigDvNBlp X-Received: by 2002:a62:7a8e:0:b0:447:df71:48b2 with SMTP id v136-20020a627a8e000000b00447df7148b2mr5800908pfc.22.1632838662976; Tue, 28 Sep 2021 07:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632838662; cv=none; d=google.com; s=arc-20160816; b=xPENkSaLrP30VupbPzyaRphwLEKmWQft8LKz3Lmk4LY0EVMxIhfpkREzkR4LJrS+iE gZVJKy4GMt9+mYwmruMnp1J0jEqM9YWyRAp22ztTqX00niT6bcTnNcwMGBw3Y79TfRhv st63MnVetmoq1x7o0i96SBmtch4XhJH2kUV1hiACd33ibwYAPf8oJ04ey8CZtu163Dva UoQzaBW7TxhDEgA0v8z3Pk7Pl5M5J8+DTzfhhrtWmdurN4goR9y/3c6QS+he2b8ZE73M 2taW7LPQlW9652nRdvXge5mKIJDHEIRrONEg6r0ziKy6Jp42NknBRjqT79Ls86XdBBvA fLLw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=V1v25WDPu4S65BGeMIG9F3Uek6zupyB1HkMjnsUWjjY=; b=tDQoTpK6fDWILNeAQFaXLJOe4tGxM2b3p+PWhlymPfcKQXHvkA+cLmFVsFlOsmkYC5 86Mk5g8bFBYMBl26mbZ7hXU8K7QOiC5aCyEhEqjbzz3xa3qvQOxIxH4ikD9BtjNwFoMF QljpHugntJLj2Boo24BzeO6UpF9YofTmgU+vIgRZB6eetoku4+4QpNfMmET+Y91C3fCJ 7FjXkFpAjq1L+GU+y87X9gLFOmwhrfDw0valotScdab/9fI4CSdg6yT+8DLeo6C9ExfE a3gMtTE+AMiLOe+lnn4r0b4fuQDHsSsFNYWx/vyDftP1BvGEQpcQDxgQGWtjRufaBY0d Ki1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=BkT+hA8z; 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 e25si27708397pgv.106.2021.09.28.07.17.21; Tue, 28 Sep 2021 07:17:42 -0700 (PDT) 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=BkT+hA8z; 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 S240899AbhI1OS6 (ORCPT + 99 others); Tue, 28 Sep 2021 10:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240488AbhI1OS6 (ORCPT ); Tue, 28 Sep 2021 10:18:58 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6665C06161C; Tue, 28 Sep 2021 07:17:18 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 4509125FE; Tue, 28 Sep 2021 10:17:18 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 4509125FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1632838638; bh=V1v25WDPu4S65BGeMIG9F3Uek6zupyB1HkMjnsUWjjY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BkT+hA8zMLrUfTIYhc0zv215cClyhWm3iXoQZNNGIYsf0mIpYGE6uzhPwrA2mkjvb 8VKXVmuP/J1NWFZAd7CmIEmmkgbbvRNe8Bs/fLZ3CeNB8jlsCmSBEmlH30Tse+jx+m 6x7Lg665vUxRR2jRpTa/NQFB3lVTFK2ursVK3fN0= Date: Tue, 28 Sep 2021 10:17:18 -0400 From: "bfields@fieldses.org" To: Trond Myklebust Cc: "neilb@suse.com" , "kolga@netapp.com" , "willy@infradead.org" , "tyhicks@canonical.com" , "davem@davemloft.net" , "wanghai38@huawei.com" , "nicolas.dichtel@6wind.com" , "linux-kernel@vger.kernel.org" , "edumazet@google.com" , "jlayton@kernel.org" , "dsahern@gmail.com" , "christian.brauner@ubuntu.com" , "ast@kernel.org" , "anna.schumaker@netapp.com" , "linux-nfs@vger.kernel.org" , "viro@zeniv.linux.org.uk" , "kuba@kernel.org" , "cong.wang@bytedance.com" , "chuck.lever@oracle.com" , "kuniyu@amazon.co.jp" , "timo@rothenpieler.org" , "jiang.wang@bytedance.com" , "wenbin.zeng@gmail.com" , "netdev@vger.kernel.org" , "Rao.Shoaib@oracle.com" , "jakub.kicinski@netronome.com" , "tom@talpey.com" Subject: Re: [PATCH net 2/2] auth_gss: Fix deadlock that blocks rpcsec_gss_exit_net when use-gss-proxy==1 Message-ID: <20210928141718.GC25415@fieldses.org> References: <20210928031440.2222303-1-wanghai38@huawei.com> <20210928031440.2222303-3-wanghai38@huawei.com> <20210928134952.GA25415@fieldses.org> <77051a059fa19a7ae2390fbda7f8ab6f09514dfc.camel@hammerspace.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <77051a059fa19a7ae2390fbda7f8ab6f09514dfc.camel@hammerspace.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Sep 28, 2021 at 02:04:49PM +0000, Trond Myklebust wrote: > On Tue, 2021-09-28 at 09:49 -0400, bfields@fieldses.org wrote: > > On Tue, Sep 28, 2021 at 01:30:17PM +0000, Trond Myklebust wrote: > > > On Tue, 2021-09-28 at 11:14 +0800, Wang Hai wrote: > > > > When use-gss-proxy is set to 1, write_gssp() creates a rpc client > > > > in > > > > gssp_rpc_create(), this increases the netns refcount by 2, these > > > > refcounts are supposed to be released in rpcsec_gss_exit_net(), > > > > but > > > > it > > > > will never happen because rpcsec_gss_exit_net() is triggered only > > > > when > > > > the netns refcount gets to 0, specifically: > > > >     refcount=0 -> cleanup_net() -> ops_exit_list -> > > > > rpcsec_gss_exit_net > > > > It is a deadlock situation here, refcount will never get to 0 > > > > unless > > > > rpcsec_gss_exit_net() is called. So, in this case, the netns > > > > refcount > > > > should not be increased. > > > > > > > > In this case, xprt will take a netns refcount which is not > > > > supposed > > > > to be taken. Add a new flag to rpc_create_args called > > > > RPC_CLNT_CREATE_NO_NET_REF for not increasing the netns refcount. > > > > > > > > It is safe not to hold the netns refcount, because when > > > > cleanup_net(), it > > > > will hold the gssp_lock and then shut down the rpc client > > > > synchronously. > > > > > > > > > > > I don't like this solution at all. Adding this kind of flag is > > > going to > > > lead to problems down the road. > > > > > > Is there any reason whatsoever why we need this RPC client to exist > > > when there is no active knfsd server? IOW: Is there any reason why > > > we > > > shouldn't defer creating this RPC client for when knfsd starts up > > > in > > > this net namespace, and why we can't shut it down when knfsd shuts > > > down? > > > > The rpc create is done in the context of the process that writes to > > /proc/net/rpc/use-gss-proxy to get the right namespaces.  I don't > > know > > how hard it would be capture that information for a later create. > > > > svcauth_gss_proxy_init() uses the net namespace SVC_NET(rqstp) (i.e. > the knfsd namespace) in the call to gssp_accept_sec_context_upcall(). > > IOW: the net namespace used in the call to find the RPC client is the > one set up by knfsd, and so if use-gss-proxy was set in a different > namespace than the one used by knfsd, then it won't be found. Right. If you've got multiple containers, you don't want to find a gss-proxy from a different container. --b.