netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaliy Gusev <vgusev@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Patrick McManus <mcmanus@ducksong.com>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Pavel Emelyanov <xemul@openvz.org>,
	netdev@vger.kernel.org
Subject: [TCP]: TCP_DEFER_ACCEPT causes leak sockets
Date: Wed, 11 Jun 2008 16:58:40 +0400	[thread overview]
Message-ID: <200806111658.41182.vgusev@openvz.org> (raw)

Hello!

While testing network namespace with 2.6.26 OpenVZ kernel port I found
some problem with the patch commit ec3c0982a2dd1e671bad8e9d26c28dcba0039d87 
("[TCP]: TCP_DEFER_ACCEPT updates - process as established")


>--- a/net/ipv4/tcp_timer.c
>+++ b/net/ipv4/tcp_timer.c
>@@ -481,6 +481,11 @@ static void tcp_keepalive_timer (unsigned long data)
> 		goto death;
> 	}
> 
>+	if (tp->defer_tcp_accept.request && sk->sk_state == TCP_ESTABLISHED) {
>+		tcp_send_active_reset(sk, GFP_ATOMIC);
>+		goto death;

Here socket sk is not attached to listening socket's request queue. tcp_done() 
will not call inet_csk_destroy_sock() (and tcp_v4_destroy_sock() which should 
release this sk) as socket is not DEAD. Therefore socket sk will be lost for 
freeing.

>+	}
>+
> 	if (!sock_flag(sk, SOCK_KEEPOPEN) || sk->sk_state == TCP_CLOSE)
> 		goto out;
>
>diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
>index 0ba6e91..167a0f5 100644
>--- a/net/ipv4/tcp_ipv4.c
>+++ b/net/ipv4/tcp_ipv4.c
>@@ -1920,6 +1920,14 @@ int tcp_v4_destroy_sock(struct sock *sk)
> 		sk->sk_sndmsg_page = NULL;
> 	}
> 
>+	if (tp->defer_tcp_accept.request) {
>+		reqsk_free(tp->defer_tcp_accept.request);
>+		sock_put(tp->defer_tcp_accept.listen_sk);
>+		sock_put(sk);
>+		tp->defer_tcp_accept.listen_sk = NULL;
>+		tp->defer_tcp_accept.request = NULL;
>+	}
>+
> 	atomic_dec(&tcp_sockets_allocated);
> 
> 	return 0;

I asked Alexey Kuznetsov about this problem and he answered he didn't know 
what to do yet.

-- 
Thank,
Vitaliy Gusev

             reply	other threads:[~2008-06-11 12:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-11 12:58 Vitaliy Gusev [this message]
2008-06-11 13:57 ` [TCP]: TCP_DEFER_ACCEPT causes leak sockets Alexey Kuznetsov
2008-06-11 23:52   ` David Miller
2008-06-12 23:32     ` David Miller
2008-06-13  6:30       ` Ingo Molnar
2008-06-13  9:32         ` David Miller
2008-06-13 11:09           ` Ingo Molnar
2008-06-13 11:47             ` Ingo Molnar
2008-06-13 21:10               ` Ingo Molnar
2008-06-16 23:59               ` David Miller
2008-06-17  7:26                 ` Ingo Molnar
2008-06-17  7:38                   ` David Miller
2008-06-17  8:09                     ` Ingo Molnar
2008-06-17  8:32                       ` Ingo Molnar
2008-06-17  9:08                         ` David Miller
2008-06-17  9:27                           ` Ingo Molnar
2008-06-17  9:29                             ` David Miller
2008-06-17  9:39                               ` Ingo Molnar
2008-06-18 18:50                                 ` [E1000-devel] " Kok, Auke
2008-06-18 20:08                                   ` Ingo Molnar
2008-06-18 21:25                                     ` [E1000-devel] " Kok, Auke
2008-06-18 22:12                                       ` David Miller
2008-06-19  7:06                                         ` Jarek Poplawski
2008-06-18 21:32                                     ` Ingo Molnar
2008-06-18 21:41                                       ` Denys Fedoryshchenko
2008-06-18 22:05                                         ` Ingo Molnar
2008-06-18 22:44                                           ` Denys Fedoryshchenko
2008-06-18 23:14                                   ` Ingo Molnar
2008-06-17  8:43                       ` Vitaliy Gusev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806111658.41182.vgusev@openvz.org \
    --to=vgusev@openvz.org \
    --cc=davem@davemloft.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=mcmanus@ducksong.com \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).