Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4523011pxb; Mon, 27 Sep 2021 20:16:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8pdzNqc+LV/haAYoyq1AKxilIni6DfJRINz4CP6HBiVv2RLTh3k5n5cQMtlTgJyTXFlFy X-Received: by 2002:a63:2a0e:: with SMTP id q14mr2560008pgq.217.1632798964994; Mon, 27 Sep 2021 20:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632798964; cv=none; d=google.com; s=arc-20160816; b=wJm32pYRARRHcOUVAP4DSN0yHmvIKJN16jmtWAyxPnfWp5rc9yM9wQQhoFrF5mCj6x l0baklD5qVWnwXPCyBBdYKmkzbq2FwZTHWOzyGytcWg4ON/ZugVcrdcX+pxKbSToW1lX HRA7VVJ7M19TAK5uTr9gyaNI1+tKcIaV+Ibf4dYmZZ/f3rz10ELhMDcx2p1w+Y+Uz3VR oZzl8K/4KTOTz3wLs2rYTut06c0klu7xx3vvK7adoUe/NmZ8FL9wlBZv5r+WLXjlBxQJ dVI9QCFk/4G6IMXQPli82IyIgHrXux96U3cEp1LVmEjTIMM//k/zHaBFbF+DTzLj0iNo P0lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JuL0X9Y0wIL/Qs9qEtD8zEmoviJtIIcjh3gMljjbZJQ=; b=XyjblGJYZRQ117shLDDfKLhkEc4S461iJSeuWE2HeTuxd/SmipKnRfdNAUJ1lw3/Mi jnC5N4m1s7F+QxbVC4sXxjit09LgM/5St7TpAs4Xz38ps3gI9FYV4U1FQIpOD6dz41DV geinaScSzJ7qIAuAegS8mz7dXBwRTz1E4tAeeQ+eFEZEZy5YQOVGzDE8n22BYFZ/dQYB xz8d/HuplVYNIMfKyDssHYVaVymuM0kmkhoBF9VIv9fft3rUYi+PEZNEUpSvwBxNY0xb 8l+3K+RgJXyfECS09SMhDSvWWo/KXUklZbUYUK8jZIlkGZKj38HgHG4fGLhQkR6GKVnp 5FYQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me6si2122012pjb.145.2021.09.27.20.15.51; Mon, 27 Sep 2021 20:16:04 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238824AbhI1DRY (ORCPT + 99 others); Mon, 27 Sep 2021 23:17:24 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:12736 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238762AbhI1DRW (ORCPT ); Mon, 27 Sep 2021 23:17:22 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HJPk80NK3zWVRK; Tue, 28 Sep 2021 11:14:24 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 28 Sep 2021 11:15:41 +0800 Received: from huawei.com (10.175.104.82) 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.2308.8; Tue, 28 Sep 2021 11:15:39 +0800 From: Wang Hai To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH net 1/2] net: Modify unix_stream_connect to not reference count the netns of kernel sockets Date: Tue, 28 Sep 2021 11:14:39 +0800 Message-ID: <20210928031440.2222303-2-wanghai38@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928031440.2222303-1-wanghai38@huawei.com> References: <20210928031440.2222303-1-wanghai38@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When use-gss-proxy is set to 1, write_gssp() creates a rpc client in gssp_rpc_create(), this increases 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 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, kernel_connect()->unix_stream_connect() will take a netns refcount. According to commit 26abe14379f8 ("net: Modify sk_alloc to not reference count the netns of kernel sockets."), kernel sockets should not take the netns refcount, so unix_stream_connect() should not take the netns refcount when the sock is a kernel socket either. Signed-off-by: Wang Hai --- net/unix/af_unix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 92345c9bb60c..af6ba67779c8 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1317,7 +1317,8 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, err = -ENOMEM; /* create new sock for complete connection */ - newsk = unix_create1(sock_net(sk), NULL, 0, sock->type); + newsk = unix_create1(sock_net(sk), NULL, + !sk->sk_net_refcnt, sock->type); if (newsk == NULL) goto out; -- 2.17.1