[PATCH 07/13] autofs-5.1.4 - fix fd leak in rpc_do_create_client()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 94f87e203a (fix create_client() RPC client handling) fixed
possible use of an invalid RPC client handle but the change neglected
to account for a check in rpc_do_create_client() that would open a new
file descriptor without checking if the passed in descriptor was
already opened.

Signed-off-by: Ian Kent <raven@xxxxxxxxxx>
---
 CHANGELOG      |    1 +
 lib/rpc_subs.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index dd48bf71..92e60df9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -25,6 +25,7 @@ xx/xx/2018 autofs-5.1.5
 - add units After line to include statd service.
 - use systemd sd_notify() at startup.
 - fix NFS version mask usage.
+- fix fd leak in rpc_do_create_client().
 
 19/12/2017 autofs-5.1.4
 - fix spec file url.
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
index cc83e84d..9451c455 100644
--- a/lib/rpc_subs.c
+++ b/lib/rpc_subs.c
@@ -183,7 +183,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
 	in4_laddr.sin_addr.s_addr = htonl(INADDR_ANY);
 	slen = sizeof(struct sockaddr_in);
 
-	if (!info->client) {
+	if (!info->client && *fd == RPC_ANYSOCK) {
 		struct sockaddr *laddr;
 
 		*fd = open_sock(addr->sa_family, type, proto);
@@ -296,7 +296,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
 	 * it would bind to a reserved port, which has been shown to
 	 * exhaust the reserved port range in some situations.
 	 */
-	if (!info->client) {
+	if (!info->client && *fd == RPC_ANYSOCK) {
 		*fd = open_sock(addr->sa_family, type, proto);
 		if (*fd < 0) {
 			ret = -errno;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in



[Index of Archives]     [Linux Filesystem Development]     [Linux Ext4]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux