Skip to contentSkip to conversation

tcp: Fix crash in TCP Fast Open

PATCH Applied Ben Hutchings 6 participants 8 messages Apr 15, 2015 – May 1, 2015

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

PATCH 1/1 tcp: Fix crash in TCP Fast Open

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

---
 net/ipv4/tcp_output.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_output.c +1 -0
index d5457e4..1ea0a07 100644
@@ -2992,6 +2992,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
 		goto fallback;
 	syn_data->ip_summed = CHECKSUM_PARTIAL;
 	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
+	skb_shinfo(syn_data)->gso_segs = 1;
 	if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
 					 fo->data->msg_iov, 0, space))) {
 		kfree_skb(syn_data);
Signature · 3 lines
Ben Hutchings
Editing code like this is akin to sticking plasters on the bleeding stump
of a severed limb. - me, 29 June 1999
Acked-by on v1 1/1
#1 lore raw
Quoted 27 lines · Ben Hutchings

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

---
 net/ipv4/tcp_output.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_output.c +0 -0
index d5457e4..1ea0a07 100644

net/ipv4/tcp_output.c static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn) · line 2998

Quoted 7 lines
net/ipv4/tcp_output.c +1 -0
@@ -2992,6 +2992,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
 		goto fallback;
 	syn_data->ip_summed = CHECKSUM_PARTIAL;
 	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
+	skb_shinfo(syn_data)->gso_segs = 1;
 	if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
 					 fo->data->msg_iov, 0, space))) {
 		kfree_skb(syn_data);

Looks goot to me, thanks Ben !

maintainer
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Wed, 15 Apr 2015 11:22:44 -0700

Quoted 18 lines · Ben Hutchings
Quoted 17 lines

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

...

Quoted 3 lines

Looks goot to me, thanks Ben !

Ben, thanks for taking care of this.

#3 lore raw
In reply to Ben Hutchings
Quoted 9 lines · Ben Hutchings

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Quoted 8 lines

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

Thanks a lot, Ben. I'll queue this for the next 3.16 kernel release.

Cheers,
--
Luís

Quoted 21 lines
---
 net/ipv4/tcp_output.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_output.c +1 -0
index d5457e4..1ea0a07 100644
@@ -2992,6 +2992,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
 		goto fallback;
 	syn_data->ip_summed = CHECKSUM_PARTIAL;
 	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
+	skb_shinfo(syn_data)->gso_segs = 1;
 	if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
 					 fo->data->msg_iov, 0, space))) {
 		kfree_skb(syn_data);
Signature · 4 lines
-- 
Ben Hutchings
Editing code like this is akin to sticking plasters on the bleeding stump
of a severed limb. - me, 29 June 1999
maintainer
#4 lore raw
In reply to Ben Hutchings
Quoted 14 lines · Ben Hutchings

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Quoted 6 lines

Set skb_shared_info::gso_segs to the correct value of 1.

---
 net/ipv4/tcp_output.c | 1 +
 1 file changed, 1 insertion(+)

Thanks for working on this and sending the patch out.

greg k-h

maintainer Applied
#5 lore raw

Patch "tcp: Fix crash in TCP Fast Open" has been added to the 3.10-stable tree

In reply to Ben Hutchings

This is a note to let you know that I've just added the patch titled

tcp: Fix crash in TCP Fast Open

to the 3.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
tcp-fix-crash-in-tcp-fast-open.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Fri Apr 17 11:41:49 2015

From: Ben Hutchings <[email protected]>
Date: Wed, 15 Apr 2015 19:00:32 +0100
Subject: tcp: Fix crash in TCP Fast Open
To: stable <[email protected]>
Cc: netdev <[email protected]>, Eric Dumazet <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Ben Hutchings <[email protected]>

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

---
 net/ipv4/tcp_output.c |    1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_output.c +1 -0
@@ -2909,6 +2909,7 @@ static int tcp_send_syn_data(struct sock
 		goto fallback;
 	syn_data->ip_summed = CHECKSUM_PARTIAL;
 	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
+	skb_shinfo(syn_data)->gso_segs = 1;
 	if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
 					 fo->data->msg_iov, 0, space))) {
 		kfree_skb(syn_data);

Patches currently in stable-queue which might be from [email protected] are

queue-3.10/tcp-fix-crash-in-tcp-fast-open.patch

maintainer Applied
#6 lore raw

Patch "tcp: Fix crash in TCP Fast Open" has been added to the 3.14-stable tree

In reply to Ben Hutchings

This is a note to let you know that I've just added the patch titled

tcp: Fix crash in TCP Fast Open

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
tcp-fix-crash-in-tcp-fast-open.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Fri Apr 17 11:41:49 2015

From: Ben Hutchings <[email protected]>
Date: Wed, 15 Apr 2015 19:00:32 +0100
Subject: tcp: Fix crash in TCP Fast Open
To: stable <[email protected]>
Cc: netdev <[email protected]>, Eric Dumazet <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Ben Hutchings <[email protected]>

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

---
 net/ipv4/tcp_output.c |    1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_output.c +1 -0
@@ -2933,6 +2933,7 @@ static int tcp_send_syn_data(struct sock
 		goto fallback;
 	syn_data->ip_summed = CHECKSUM_PARTIAL;
 	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
+	skb_shinfo(syn_data)->gso_segs = 1;
 	if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
 					 fo->data->msg_iov, 0, space))) {
 		kfree_skb(syn_data);

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/tcp-fix-crash-in-tcp-fast-open.patch

#7 lore raw
In reply to Ben Hutchings
Quoted 9 lines · Ben Hutchings

Commit 355a901e6cf1 ("tcp: make connect() mem charging friendly") changed tcp_send_syn_data() to perform an open-coded copy of the 'syn' skb rather than using skb_copy_expand().

The open-coded copy does not cover the skb_shared_info::gso_segs field, so in the new skb it is left set to 0. When this commit was backported into stable branches between 3.10.y and 3.16.7-ckty inclusive, it triggered the BUG() in tcp_transmit_skb().

Quoted 8 lines

Since Linux 3.18 the GSO segment count is kept in the tcp_skb_cb::tcp_gso_segs field and tcp_send_syn_data() does copy the tcp_skb_cb structure to the new skb, so mainline and newer stable branches are not affected.

Set skb_shared_info::gso_segs to the correct value of 1.

Queued for 3.13-stable. Thanks very much, Ben!

-Kamal

Quoted 17 lines
---
 net/ipv4/tcp_output.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_output.c +1 -0
index d5457e4..1ea0a07 100644
@@ -2992,6 +2992,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
 		goto fallback;
 	syn_data->ip_summed = CHECKSUM_PARTIAL;
 	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
+	skb_shinfo(syn_data)->gso_segs = 1;
 	if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
 					 fo->data->msg_iov, 0, space))) {
 		kfree_skb(syn_data);