Skip to contentSkip to conversation

: Make kernel level struct socket->ops->accept() use sock_create_lite()

PATCH New Nicholas A. Bellinger 1 participant 1 message Nov 26, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Make kernel level struct socket->ops->accept() use sock_create_lite()

Quoted 1 line

From 0450272b62a9944c2efe9d038447e168abba41a0 Mon Sep 17 00:00:00 2001

From: Nicholas Bellinger <[email protected]>
Date: Tue, 25 Nov 2008 19:51:13 -0800
Subject: [PATCH] [LIO-Target]: Make kernel level struct socket->ops->accept() use sock_create_lite()

With the addition sock_create_lite() in Linux v2.6.6, and at somepoint thereafter, the 'struct socket->sock' pointer of struct sock allocated internally with kmem_cache_alloc() via net/core/sock.c:sk_prot_alloc() in net/socket.c:sock_create() was
being leaked (silently below the API) with with struct newsock usage with struct socket->ops->accept(). This meant that normally calling net/socket.c:sock_release() to the struct socket->ops->accept()'ed struct sock (located at struct socket->sock) was not releasing struct sock back into struct proto->slab in net/core/sock.c:sk_free().

This patch to LIO-Target follows what net/socket.c:kernel_accept() does and uses sock_create_lite(). kernel_accept() was added in v2.6.19, so one can assume the silient leak with sock_create() and struct socket->ops->accept() was introduced sometime between v2.6.6 and v2.6.19..

In LIO-Target code, iscsi_target_login.c:iscsi_target_login_thread() now uses sock_create_lite() for struct socket->ops->accept() usage.

Forward port from v2.9-STABLE r406

---
 drivers/lio-core/iscsi_target_login.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/lio-core/iscsi_target_login.c +2 -2
index 0b0a54a..302f527 100644
@@ -763,9 +763,9 @@ static struct socket *iscsi_target_setup_login_socket (iscsi_np_t *np)
 		goto fail;
 	}
 	
-	if (sock_create((np->np_flags & NPF_NET_IPV6) ? AF_INET6 : AF_INET,
+	if (sock_create_lite((np->np_flags & NPF_NET_IPV6) ? AF_INET6 : AF_INET,
 			sock_type, ip_proto, &sock) < 0) {
-		TRACE_ERROR("sock_create() failed.\n");
+		TRACE_ERROR("sock_create_lite() failed.\n");
 		goto fail;
 	}
 	np->np_socket = sock;
Signature · 1 line
1.5.4.1