Skip to contentSkip to conversation

tcp: fix "old stuff" D-SACK causing SACK to be treated as D-SACK

PATCH In review Pengcheng Yang 4 participants 4 messages Dec 30, 2019 – Jan 2, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: fix "old stuff" D-SACK causing SACK to be treated as D-SACK

When we receive a D-SACK, where the sequence number satisfies:
undo_marker <= start_seq < end_seq <= prior_snd_una
we consider this is a valid D-SACK and tcp_is_sackblock_valid() returns true, then this D-SACK is discarded as "old stuff", but the variable first_sack_index is not marked as negative in tcp_sacktag_write_queue().

If this D-SACK also carries a SACK that needs to be processed (for example, the previous SACK segment was lost), this SACK will be treated as a D-SACK in the following processing of tcp_sacktag_write_queue(), which will eventually lead to incorrect updates of undo_retrans and reordering.

Fixes fd6dad616d4f ("[TCP]: Earlier SACK block verification & simplify access to them")
---
 net/ipv4/tcp_input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +4 -1
index 88b987c..0238b55 100644
@@ -1727,8 +1727,11 @@ static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl
 		}
 
 		/* Ignore very old stuff early */
-		if (!after(sp[used_sacks].end_seq, prior_snd_una))
+		if (!after(sp[used_sacks].end_seq, prior_snd_una)) {
+			if (i == 0)
+				first_sack_index = -1;
 			continue;
+		}
 
 		used_sacks++;
 	}
Signature · 1 line
1.8.0
#1 lore raw
Quoted 10 lines · Pengcheng Yang

When we receive a D-SACK, where the sequence number satisfies:
undo_marker <= start_seq < end_seq <= prior_snd_una
we consider this is a valid D-SACK and tcp_is_sackblock_valid() returns true, then this D-SACK is discarded as "old stuff", but the variable first_sack_index is not marked as negative in tcp_sacktag_write_queue().

If this D-SACK also carries a SACK that needs to be processed (for example, the previous SACK segment was lost),

What do you mean by ' previous sack segment was lost' ?

this SACK

Quoted 17 lines

will be treated as a D-SACK in the following processing of tcp_sacktag_write_queue(), which will eventually lead to incorrect updates of undo_retrans and reordering.

Fixes fd6dad616d4f ("[TCP]: Earlier SACK block verification & simplify access to them")
---
 net/ipv4/tcp_input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +0 -0
index 88b987c..0238b55 100644
@@ -1727,8 +1727,11 @@ static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl
                }
 

net/ipv4/tcp_input.c static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl · line 1737

Quoted 10 lines
net/ipv4/tcp_input.c +4 -1
                /* Ignore very old stuff early */
-               if (!after(sp[used_sacks].end_seq, prior_snd_una))
+               if (!after(sp[used_sacks].end_seq, prior_snd_una)) {
+                       if (i == 0)
+                               first_sack_index = -1;
                        continue;
+               }
 
                used_sacks++;
        }

Hi Pengcheng Yang

This corner case deserves a packetdrill test so that we understand the issue, can you provide one ?

Thanks.

#2 lore raw
In reply to Pengcheng Yang
Quoted 27 lines · Pengcheng Yang

When we receive a D-SACK, where the sequence number satisfies:
undo_marker <= start_seq < end_seq <= prior_snd_una
we consider this is a valid D-SACK and tcp_is_sackblock_valid() returns true, then this D-SACK is discarded as "old stuff", but the variable first_sack_index is not marked as negative in tcp_sacktag_write_queue().

If this D-SACK also carries a SACK that needs to be processed (for example, the previous SACK segment was lost), this SACK will be treated as a D-SACK in the following processing of tcp_sacktag_write_queue(), which will eventually lead to incorrect updates of undo_retrans and reordering.

Fixes fd6dad616d4f ("[TCP]: Earlier SACK block verification & simplify access to them")
---
 net/ipv4/tcp_input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +0 -0
index 88b987c..0238b55 100644
@@ -1727,8 +1727,11 @@ static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl
 		}
 

net/ipv4/tcp_input.c static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl · line 1737

Quoted 10 lines
net/ipv4/tcp_input.c +4 -1
 		/* Ignore very old stuff early */
-		if (!after(sp[used_sacks].end_seq, prior_snd_una))
+		if (!after(sp[used_sacks].end_seq, prior_snd_una)) {
+			if (i == 0)
+				first_sack_index = -1;
 			continue;
+		}
 
 		used_sacks++;
 	}

Thanks for fixing this.

maintainer
#3 lore raw
In reply to Pengcheng Yang

From: Pengcheng Yang <[email protected]>
Date: Mon, 30 Dec 2019 17:54:41 +0800

Quoted 7 lines

When we receive a D-SACK, where the sequence number satisfies:
undo_marker <= start_seq < end_seq <= prior_snd_una
we consider this is a valid D-SACK and tcp_is_sackblock_valid() returns true, then this D-SACK is discarded as "old stuff", but the variable first_sack_index is not marked as negative in tcp_sacktag_write_queue().

Quoted 8 lines

If this D-SACK also carries a SACK that needs to be processed (for example, the previous SACK segment was lost), this SACK will be treated as a D-SACK in the following processing of tcp_sacktag_write_queue(), which will eventually lead to incorrect updates of undo_retrans and reordering.

Fixes fd6dad616d4f ("[TCP]: Earlier SACK block verification & simplify access to them")

Applied and queued up for -stable, thank you.