lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220511132232.4030-4-wanghai38@huawei.com>
Date:   Wed, 11 May 2022 21:22:32 +0800
From:   Wang Hai <wanghai38@...wei.com>
To:     <trond.myklebust@...merspace.com>, <bfields@...ldses.org>,
        <anna@...nel.org>, <chuck.lever@...cle.com>, <davem@...emloft.net>,
        <kuba@...nel.org>, <pabeni@...hat.com>
CC:     <linux-nfs@...r.kernel.org>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <wanghai38@...wei.com>
Subject: [PATCH 3/3] SUNRPC: Fix local socket leak in xs_setup_local()

Add mechanism in xs_setup_local() to safely tear xprt down and
solve the socket leak problem.

Signed-off-by: Wang Hai <wanghai38@...wei.com>
---
 net/sunrpc/xprtsock.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 25b8a8ead56b..7b9a62750571 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1264,6 +1264,18 @@ static void xs_xprt_free(struct rpc_xprt *xprt)
 	xprt_free(xprt);
 }
 
+/**
+ * xs_destroy_xprt - close xprt socket and destroy it.
+ */
+static void xs_destroy_xprt(struct work_struct *work)
+{
+	struct rpc_xprt *xprt =
+		container_of(work, struct rpc_xprt, task_cleanup);
+
+	xs_close(xprt);
+	xs_xprt_free(xprt);
+}
+
 /**
  * xs_destroy - prepare to shutdown a transport
  * @xprt: doomed transport
@@ -2891,7 +2903,9 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
 		return xprt;
 	ret = ERR_PTR(-EINVAL);
 out_err:
-	xs_xprt_free(xprt);
+
+	INIT_WORK(&xprt->task_cleanup, xs_destroy_xprt);
+	schedule_work(&xprt->task_cleanup);
 	return ret;
 }
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ