Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1269555iob; Fri, 29 Apr 2022 01:16:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY6/NIeQjljdFeMDN3YdpdRmWrjKACvK4EKeU26acyGEPleZ+70/Q2JIhfgn3PIUYrgpZy X-Received: by 2002:a17:90b:33ca:b0:1d7:d322:9aa2 with SMTP id lk10-20020a17090b33ca00b001d7d3229aa2mr2567582pjb.21.1651220180744; Fri, 29 Apr 2022 01:16:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651220180; cv=none; d=google.com; s=arc-20160816; b=Kl65jQamUoLfjG58LbshfRC+Ja3lukZAgnyVEiV6vH5fc5KxJdGmiyeVqiH7UVnfTl o7O9Zy4nHLzlhI/mx9IOdNNr/xxMvBUdKMA1R77iOlxrlBcs3JXvba1IJzqOslO8D5SH iQ49cexXyUYykQHSBecqw6w3+U0ilcliVg7BMl8eE8zfzjfy6b8hIUOWHGMTU0hwPzmQ aKk+kUDULtgImNF3bExWgh7ZeXVjjpKZfGa0aSyRbdv4wsLxJUhQmK4+NCk/+Hv6CWyl 5zqIvlky1mkaXZ+Bo1mWO+qI7z8ZwfJOOqoNAj3PCJhLtq0M/dEeHL6x1OCfF5QowGsE d2LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=4xXbusy6Slw4W597jSrY6wTnODb+gVnPK91QaTXjB/M=; b=iY5bCO88PcUFZMVDiZzn/BdiwHn3OH5RQW9BNzcg20tmlzCRtD5Ie6srJb0n+OtOUm 84pF9xCl/cTDaYGFrlNINHIoeLUOQZGaD2Uf8MwgFh+VYJDSH2GY9G0yOparXs81vq+5 66fXAT7a43JtyTUYwD7klHRMEtS0daV+zTpkhXFNNl51n+B+O6tNAGaGGLAkSFHD6q87 cupg5H+0XD8UGaH6N22vSyshgHyRHvPl8Lr3FEfzY4QWwaQ4tFvRkvC7DwwTkPYFoVsG D4t8jvK0wpuI12PtxS/LMRofRmv2jW8UItiUn29yLbWhYheUDnTOkJB989hSu3Zw51Fo McIQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a170902ba8c00b00153b2d1657esi6094958pls.390.2022.04.29.01.15.51; Fri, 29 Apr 2022 01:16:20 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349275AbiD2Bq4 (ORCPT + 99 others); Thu, 28 Apr 2022 21:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbiD2Bqz (ORCPT ); Thu, 28 Apr 2022 21:46:55 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0281BF333 for ; Thu, 28 Apr 2022 18:43:38 -0700 (PDT) Received: from kwepemi100014.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KqFch1qy0zhYSP; Fri, 29 Apr 2022 09:43:16 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by kwepemi100014.china.huawei.com (7.221.188.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Apr 2022 09:43:36 +0800 Received: from [10.174.176.245] (10.174.176.245) by kwepemm600001.china.huawei.com (7.193.23.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Apr 2022 09:43:36 +0800 Message-ID: <2bd62035-21eb-d4a4-0ad6-32e90a674d70@huawei.com> Date: Fri, 29 Apr 2022 09:43:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 1/2] SUNRPC: Don't leak sockets in xs_local_connect() To: , References: <20220428153001.9545-1-trondmy@kernel.org> From: "wanghai (M)" In-Reply-To: <20220428153001.9545-1-trondmy@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.245] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 在 2022/4/28 23:30, trondmy@kernel.org 写道: > From: Trond Myklebust > > If there is still a closed socket associated with the transport, then we > need to trigger an autoclose before we can set up a new connection. > > Reported-by: wanghai (M) > Fixes: f00432063db1 ("SUNRPC: Ensure we flush any closed sockets before xs_xprt_free()") > Signed-off-by: Trond Myklebust > --- > net/sunrpc/xprtsock.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) Hi, Trond. Thank you for taking the time to help! I tested it with this patch and found that the problem still exists. The path of the sock leak is as follows and is not in xs_local_connect() write_ports   nfsd_create_serv     svc_bind       rpcb_create_local         rpcb_create_local_unix           rpc_create             xprt_create_transport               xs_setup_local                 xs_local_setup_socket > diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c > index 8ab64ea46870..f9849b297ea3 100644 > --- a/net/sunrpc/xprtsock.c > +++ b/net/sunrpc/xprtsock.c > @@ -1950,6 +1950,9 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task) > struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); > int ret; > > + if (transport->file) > + goto force_disconnect; > + > if (RPC_IS_ASYNC(task)) { > /* > * We want the AF_LOCAL connect to be resolved in the > @@ -1962,11 +1965,17 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task) > */ > task->tk_rpc_status = -ENOTCONN; > rpc_exit(task, -ENOTCONN); > - return; > + goto out_wake; > } > ret = xs_local_setup_socket(transport); > if (ret && !RPC_IS_SOFTCONN(task)) > msleep_interruptible(15000); > + return; > +force_disconnect: > + xprt_force_disconnect(xprt); > +out_wake: > + xprt_clear_connecting(xprt); > + xprt_wake_pending_tasks(xprt, -ENOTCONN); > } > > #if IS_ENABLED(CONFIG_SUNRPC_SWAP) -- Wang Hai