From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
To: David Miller <davem@davemloft.net>,
mingo@elte.hu, mcmanus@ducksong.com, peterz@infradead.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Netdev <netdev@vger.kernel.org>,
rjw@sisk.pl, Andrew Morton <akpm@linux-foundation.org>,
johnpol@2ka.mipt.ru
Subject: Re: [fixed] [patch] Re: [bug] stuck localhost TCP connections, v2.6.26-rc3+
Date: Wed, 4 Jun 2008 02:22:16 +0300 (EEST) [thread overview]
Message-ID: <Pine.LNX.4.64.0806040208350.7315@wrl-59.cs.helsinki.fi> (raw)
In-Reply-To: <20080603.150344.145518113.davem@davemloft.net>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 3981 bytes --]
On Tue, 3 Jun 2008, David Miller wrote:
> From: "Ilpo_Järvinen" <ilpo.jarvinen@helsinki.fi>
> Date: Wed, 4 Jun 2008 01:01:25 +0300 (EEST)
>
> > On Wed, 4 Jun 2008, Ilpo Järvinen wrote:
> >
> > > ...I couldn't immediately find anything obviously wrong with those changes
> > > but the patch below might be worth of a try (without the revert of
> > > course). If it ever spits out that WARN_ON for you, we were playing with
> > > fire too much and it's better to return on the safe side there...
> >
> >
> > > [PATCH] tcp DEFER_ACCEPT: see if header prediction got turned on
> > >
> > > If header prediction is turned on under some circumstances,
> > > DA can deadlock though I have great trouble in figuring out
> >
> > ...Nah, keepalive timer would then eventually kill it then, so no
> > deadlock seems possible through that one.
>
> Keepalive is very long, it might still "seem" like a deadlock for
> someone without much patience :-)
I think we want that clearing there, it's better to be safe than sorry
there and to not put any trust on the keepalive thingie which tears down
rather than results in a connection.
But here's somewhat more likely explanation... Only compile tested...
It probably needs some commenting from people who understand locking
variants & details (I don't).
--
i.
--
[PATCH] tcp DEFER_ACCEPT: fix racy access to listen_sk
It seems that replacement of DA code also moved parts outside
of appropriate locking. The Ingo's problem seems to come from
the fact that two flows could now race in
(inet_csk_)reqsk_queue_add corrupting the queue. ...This can
leave dangling socks around which won't resolve themselves
without stimuli from outside (e.g., external RST would help
I think).
Then some details I'm not too sure of:
I guess we want to put listen_sk->sk_state checking under the
lock as well. I've not evaluated if ->sk_data_ready too
requires locking but assumed it does.
I'm by no means familiar with all locking variants, requirements,
etc.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
net/ipv4/tcp_input.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index c9454f0..d21d2b9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4562,6 +4562,7 @@ static int tcp_defer_accept_check(struct sock *sk)
struct tcp_sock *tp = tcp_sk(sk);
if (tp->defer_tcp_accept.request) {
+ struct sock *listen_sk = tp->defer_tcp_accept.listen_sk;
int queued_data = tp->rcv_nxt - tp->copied_seq;
int hasfin = !skb_queue_empty(&sk->sk_receive_queue) ?
tcp_hdr((struct sk_buff *)
@@ -4570,8 +4571,9 @@ static int tcp_defer_accept_check(struct sock *sk)
if (queued_data && hasfin)
queued_data--;
- if (queued_data &&
- tp->defer_tcp_accept.listen_sk->sk_state == TCP_LISTEN) {
+ bh_lock_sock(listen_sk);
+
+ if (queued_data && listen_sk->sk_state == TCP_LISTEN) {
if (sock_flag(sk, SOCK_KEEPOPEN)) {
inet_csk_reset_keepalive_timer(sk,
keepalive_time_when(tp));
@@ -4579,23 +4581,24 @@ static int tcp_defer_accept_check(struct sock *sk)
inet_csk_delete_keepalive_timer(sk);
}
- inet_csk_reqsk_queue_add(
- tp->defer_tcp_accept.listen_sk,
- tp->defer_tcp_accept.request,
- sk);
+ inet_csk_reqsk_queue_add(listen_sk,
+ tp->defer_tcp_accept.request,
+ sk);
tp->defer_tcp_accept.listen_sk->sk_data_ready(
- tp->defer_tcp_accept.listen_sk, 0);
+ listen_sk, 0);
- sock_put(tp->defer_tcp_accept.listen_sk);
+ sock_put(listen_sk);
sock_put(sk);
tp->defer_tcp_accept.listen_sk = NULL;
tp->defer_tcp_accept.request = NULL;
- } else if (hasfin ||
- tp->defer_tcp_accept.listen_sk->sk_state != TCP_LISTEN) {
+ } else if (hasfin || listen_sk->sk_state != TCP_LISTEN) {
+ bh_unlock_sock(listen_sk);
tcp_reset(sk);
return -1;
}
+
+ bh_unlock_sock(listen_sk);
}
return 0;
}
--
1.5.2.2
next prev parent reply other threads:[~2008-06-03 23:22 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-26 11:56 [bug] stuck localhost TCP connections, v2.6.26-rc3+ Ingo Molnar
2008-05-26 13:28 ` Ilpo Järvinen
2008-05-26 13:59 ` Ingo Molnar
2008-05-26 14:12 ` Ingo Molnar
2008-05-26 14:17 ` Ingo Molnar
2008-05-26 14:29 ` Ingo Molnar
2008-05-26 14:43 ` Ilpo Järvinen
2008-05-26 14:58 ` Ilpo Järvinen
2008-05-26 16:23 ` Ingo Molnar
2008-05-26 16:32 ` Ilpo Järvinen
2008-05-26 16:54 ` Ingo Molnar
2008-05-26 17:08 ` Ilpo Järvinen
2008-05-26 18:12 ` Ingo Molnar
2008-05-26 20:41 ` Ingo Molnar
2008-05-26 21:20 ` Ilpo Järvinen
2008-05-30 16:23 ` Ray Lee
2008-05-26 16:24 ` Arjan van de Ven
2008-05-28 9:27 ` Peter Zijlstra
2008-05-31 14:25 ` Håkon Løvdal
2008-05-31 16:09 ` Ilpo Järvinen
2008-05-31 17:22 ` Ilpo Järvinen
2008-05-31 17:58 ` Håkon Løvdal
2008-05-31 18:37 ` Ilpo Järvinen
2008-05-31 20:25 ` Håkon Løvdal
2008-05-31 21:39 ` Ilpo Järvinen
2008-05-31 21:45 ` Håkon Løvdal
2008-06-04 0:10 ` Håkon Løvdal
2008-06-04 11:14 ` Ilpo Järvinen
2008-06-04 14:00 ` Håkon Løvdal
2008-06-04 15:09 ` Ilpo Järvinen
2008-06-06 9:32 ` Håkon Løvdal
2008-06-09 19:24 ` Ilpo Järvinen
2008-06-10 23:26 ` Håkon Løvdal
2008-06-11 13:39 ` Ilpo Järvinen
2008-06-19 0:30 ` Håkon Løvdal
2008-05-29 8:45 ` Ingo Molnar
2008-05-29 11:14 ` Ilpo Järvinen
2008-05-29 11:22 ` Ingo Molnar
2008-05-29 13:05 ` Evgeniy Polyakov
2008-05-29 13:43 ` Ingo Molnar
2008-05-29 13:08 ` Ingo Molnar
2008-05-29 13:48 ` Ilpo Järvinen
2008-05-30 11:09 ` Ingo Molnar
2008-05-30 21:12 ` Ilpo Järvinen
2008-05-30 18:18 ` Ingo Molnar
2008-05-31 6:09 ` Ingo Molnar
2008-05-31 11:46 ` Ilpo Järvinen
2008-05-31 12:18 ` Ilpo Järvinen
2008-05-31 12:54 ` Ingo Molnar
2008-05-31 12:58 ` Ilpo Järvinen
2008-05-31 16:35 ` Ingo Molnar
2008-05-31 22:46 ` Patrick McManus
2008-06-01 5:51 ` Ilpo Järvinen
2008-06-01 6:04 ` Eric Dumazet
2008-06-02 9:23 ` Ingo Molnar
2008-06-03 9:40 ` [fixed] [patch] " Ingo Molnar
2008-06-03 14:41 ` Patrick McManus
2008-06-03 21:46 ` Ilpo Järvinen
2008-06-03 22:01 ` Ilpo Järvinen
2008-06-03 22:03 ` David Miller
2008-06-03 22:10 ` Ilpo Järvinen
2008-06-03 23:22 ` Ilpo Järvinen [this message]
2008-06-03 23:54 ` Joe Perches
2008-06-04 6:25 ` Ilpo Järvinen
2008-06-04 2:54 ` Patrick McManus
2008-06-04 6:42 ` Ilpo Järvinen
2008-06-05 14:22 ` Ingo Molnar
2008-06-05 18:00 ` Ilpo Järvinen
2008-06-05 21:13 ` Ilpo Järvinen
2008-06-05 23:29 ` Patrick McManus
2008-06-06 10:03 ` Ilpo Järvinen
2008-06-06 17:11 ` Patrick McManus
2008-06-06 17:33 ` Ingo Molnar
2008-06-06 18:19 ` Ilpo Järvinen
2008-06-06 18:39 ` Ingo Molnar
2008-06-06 19:49 ` Ilpo Järvinen
2008-06-06 20:08 ` Patrick McManus
2008-06-06 21:12 ` Ilpo Järvinen
2008-06-06 21:23 ` Arjan van de Ven
2008-06-06 21:28 ` Ilpo Järvinen
2008-06-10 22:49 ` David Miller
2008-06-06 18:25 ` Ilpo Järvinen
2008-06-10 22:32 ` David Miller
2008-06-11 13:10 ` Patrick McManus
2008-06-11 15:13 ` Ilpo Järvinen
2008-06-04 7:23 ` Ingo Molnar
2008-06-04 18:24 ` David Miller
2008-06-04 20:56 ` Ilpo Järvinen
2008-06-04 21:55 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2008-06-11 15:06 Alexey Kuznetsov
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=Pine.LNX.4.64.0806040208350.7315@wrl-59.cs.helsinki.fi \
--to=ilpo.jarvinen@helsinki.fi \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=johnpol@2ka.mipt.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mcmanus@ducksong.com \
--cc=mingo@elte.hu \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rjw@sisk.pl \
/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).