[2.1.117] patch - Handling of RST in SYN_RECV state

Peter Benie (pjb1008@cam.ac.uk)
Sat, 22 Aug 1998 22:44:41 +0100


I've noticed that Linux 2.1 ignores RST for listening TCP sockets in
SYN_RECV. In the example below, hastur, which is listening on port 26,
is sent a SYN by medusa. hastur keeps responding with SYN-ACK despite
the RSTs from medusa. netstat shows that the socket remains in SYN_RECV.

14:55:39.549995 medusa.csi.cam.ac.uk.200 > hastur.csi.cam.ac.uk.26: S
16777216:16777216(0) win 512
14:55:39.551221 hastur.csi.cam.ac.uk.26 > medusa.csi.cam.ac.uk.200: S
353238758:353238758(0) ack 16777217 win 32696 <mss 536> (DF)
14:55:39.551486 medusa.csi.cam.ac.uk.200 > hastur.csi.cam.ac.uk.26: R
16777217:16777217(0) win 0
14:55:43.035319 hastur.csi.cam.ac.uk.26 > medusa.csi.cam.ac.uk.200: S
353238758:353238758(0) ack 16777217 win 32696 <mss 536> (DF)
14:55:43.035516 medusa.csi.cam.ac.uk.200 > hastur.csi.cam.ac.uk.26: R
16777217:16777217(0) win 0
14:55:49.537543 hastur.csi.cam.ac.uk.26 > medusa.csi.cam.ac.uk.200: S
353238758:353238758(0) ack 16777217 win 32696 <mss 536> (DF)
14:55:49.537827 medusa.csi.cam.ac.uk.200 > hastur.csi.cam.ac.uk.26: R
16777217:16777217(0) win 0
[This is repeated several times before hastur gives up.]

I believe that the bug is in tcp_v4_hnd_req(), where it checks that
the RST sequence number is in the window.

--- linux-2.1.117.orig/net/ipv4/tcp_ipv4.c Wed Jul 29 06:33:02 1998
+++ linux-2.1.117/net/ipv4/tcp_ipv4.c Sat Aug 22 21:35:56 1998
@@ -1373,8 +1373,8 @@
if (!req)
return;
/* Sequence number check required by RFC793 */
- if (before(TCP_SKB_CB(skb)->seq, req->snt_isn) ||
- after(TCP_SKB_CB(skb)->seq, req->snt_isn+1))
+ if (before(TCP_SKB_CB(skb)->seq, req->rcv_isn) ||
+ after(TCP_SKB_CB(skb)->seq, req->rcv_isn+1))
return;
tcp_synq_unlink(tp, req, prev);
(req->sk ? sk->ack_backlog : tp->syn_backlog)--;

-- 
Peter

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html