From: H.K. Jerry Chu <hidden> Date: 2012-10-22 21:28:18
From: Jerry Chu <redacted>
A packet with an invalid ack_seq may cause a TCP Fast Open socket to switch
to the unexpected TCP_CLOSING state, triggering a BUG_ON kernel panic.
When a FIN packet with an invalid ack_seq# arrives at a socket in
the TCP_FIN_WAIT1 state, rather than discarding the packet, the current
code will accept the FIN, causing state transition to TCP_CLOSING.
This may be a small deviation from RFC793, which seems to say that the
packet should be dropped. Unfortunately I did not expect this case for
Fast Open hence it will trigger a BUG_ON panic.
It turns out there is really nothing bad about a TFO socket going into
TCP_CLOSING state so I could just remove the BUG_ON statements. But after
some thought I think it's better to treat this case like TCP_SYN_RECV
and return a RST to the confused peer who caused the unacceptable ack_seq
to be generated in the first place.
Signed-off-by: H.K. Jerry Chu <redacted>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <redacted>
---
net/ipv4/tcp_input.c | 12 ++++++++++--
net/ipv4/tcp_timer.c | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
@@ -6059,7 +6059,15 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,*ACKwehavereceived,thiswouldhaveacknowledged*ourSYNACKsostoptheSYNACKtimer.*/-if(acceptable&&req!=NULL){+if(req!=NULL){+/* Return RST if ack_seq is invalid.+*NotethatRFC793onlysaystogeneratea+*DUPACKforitbutforTCPFastOpenitseems+*bettertotreatthiscaselikeTCP_SYN_RECV+*above.+*/+if(!acceptable)+return1;/* We no longer need the request sock. */reqsk_fastopen_remove(sk,req,false);tcp_rearm_rto(sk);
On Mon, Oct 22, 2012 at 2:26 PM, H.K. Jerry Chu [off-list ref] wrote:
From: Jerry Chu <redacted>
A packet with an invalid ack_seq may cause a TCP Fast Open socket to switch
to the unexpected TCP_CLOSING state, triggering a BUG_ON kernel panic.
When a FIN packet with an invalid ack_seq# arrives at a socket in
the TCP_FIN_WAIT1 state, rather than discarding the packet, the current
code will accept the FIN, causing state transition to TCP_CLOSING.
This may be a small deviation from RFC793, which seems to say that the
packet should be dropped. Unfortunately I did not expect this case for
Fast Open hence it will trigger a BUG_ON panic.
It turns out there is really nothing bad about a TFO socket going into
TCP_CLOSING state so I could just remove the BUG_ON statements. But after
some thought I think it's better to treat this case like TCP_SYN_RECV
and return a RST to the confused peer who caused the unacceptable ack_seq
to be generated in the first place.
Signed-off-by: H.K. Jerry Chu <redacted>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <redacted>
@@ -6059,7 +6059,15 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,*ACKwehavereceived,thiswouldhaveacknowledged*ourSYNACKsostoptheSYNACKtimer.*/-if(acceptable&&req!=NULL){+if(req!=NULL){+/* Return RST if ack_seq is invalid.+*NotethatRFC793onlysaystogeneratea+*DUPACKforitbutforTCPFastOpenitseems+*bettertotreatthiscaselikeTCP_SYN_RECV+*above.+*/+if(!acceptable)+return1;/* We no longer need the request sock. */reqsk_fastopen_remove(sk,req,false);tcp_rearm_rto(sk);
From: Eric Dumazet <hidden> Date: 2012-10-22 21:59:42
On Mon, 2012-10-22 at 14:26 -0700, H.K. Jerry Chu wrote:
From: Jerry Chu <redacted>
A packet with an invalid ack_seq may cause a TCP Fast Open socket to switch
to the unexpected TCP_CLOSING state, triggering a BUG_ON kernel panic.
When a FIN packet with an invalid ack_seq# arrives at a socket in
the TCP_FIN_WAIT1 state, rather than discarding the packet, the current
code will accept the FIN, causing state transition to TCP_CLOSING.
This may be a small deviation from RFC793, which seems to say that the
packet should be dropped. Unfortunately I did not expect this case for
Fast Open hence it will trigger a BUG_ON panic.
It turns out there is really nothing bad about a TFO socket going into
TCP_CLOSING state so I could just remove the BUG_ON statements. But after
some thought I think it's better to treat this case like TCP_SYN_RECV
and return a RST to the confused peer who caused the unacceptable ack_seq
to be generated in the first place.
Signed-off-by: H.K. Jerry Chu <redacted>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <redacted>
---
On Mon, Oct 22, 2012 at 5:26 PM, H.K. Jerry Chu [off-list ref] wrote:
From: Jerry Chu <redacted>
A packet with an invalid ack_seq may cause a TCP Fast Open socket to switch
to the unexpected TCP_CLOSING state, triggering a BUG_ON kernel panic.
When a FIN packet with an invalid ack_seq# arrives at a socket in
the TCP_FIN_WAIT1 state, rather than discarding the packet, the current
code will accept the FIN, causing state transition to TCP_CLOSING.
This may be a small deviation from RFC793, which seems to say that the
packet should be dropped. Unfortunately I did not expect this case for
Fast Open hence it will trigger a BUG_ON panic.
It turns out there is really nothing bad about a TFO socket going into
TCP_CLOSING state so I could just remove the BUG_ON statements. But after
some thought I think it's better to treat this case like TCP_SYN_RECV
and return a RST to the confused peer who caused the unacceptable ack_seq
to be generated in the first place.
Signed-off-by: H.K. Jerry Chu <redacted>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <redacted>
From: David Miller <davem@davemloft.net> Date: 2012-10-23 06:43:48
From: "H.K. Jerry Chu" <redacted>
Date: Mon, 22 Oct 2012 14:26:36 -0700
From: Jerry Chu <redacted>
A packet with an invalid ack_seq may cause a TCP Fast Open socket to switch
to the unexpected TCP_CLOSING state, triggering a BUG_ON kernel panic.
When a FIN packet with an invalid ack_seq# arrives at a socket in
the TCP_FIN_WAIT1 state, rather than discarding the packet, the current
code will accept the FIN, causing state transition to TCP_CLOSING.
This may be a small deviation from RFC793, which seems to say that the
packet should be dropped. Unfortunately I did not expect this case for
Fast Open hence it will trigger a BUG_ON panic.
It turns out there is really nothing bad about a TFO socket going into
TCP_CLOSING state so I could just remove the BUG_ON statements. But after
some thought I think it's better to treat this case like TCP_SYN_RECV
and return a RST to the confused peer who caused the unacceptable ack_seq
to be generated in the first place.
Signed-off-by: H.K. Jerry Chu <redacted>