diff mbox

[net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb

Message ID 1422453433.29618.58.camel@edumazet-glaptop2.roam.corp.google.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Jan. 28, 2015, 1:57 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

RST packets and ACK packets sent on behalf of TIME_WAIT sockets
do not have a socket owner currently.

For sch_fq users, this means fq classifier has to fallback to packet
dissection and allocate one flow structure, while we generally send
a single packet. This is also an attack vector.

Note that ip6_xmit() correctly uses skb_set_owner_w() if skb needs
to be reallocated when head room is not big enough.

Simply use sock_wmalloc() instead of alloc_skb().

Note: This might increase false sharing on the ctl_sk, which is
shared by all cpus for a given network namespace. We might switch later
to a percpu socket as we do for IPv4.

Also use MAX_TCP_HEADER, as it makes the code shorter.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv6/tcp_ipv6.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Dumazet Jan. 29, 2015, 9:18 p.m. UTC | #1
On Wed, 2015-01-28 at 05:57 -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> RST packets and ACK packets sent on behalf of TIME_WAIT sockets
> do not have a socket owner currently.
...
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---

Please do not apply.

I forgot about commit 3a7c384ffd57ef5fbd95f48edaa2ca4eb3d9f2ee
("ipv4: tcp: unicast_sock should not land outside of TCP stack")

I need to do this in another way.

Thanks


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet Jan. 29, 2015, 9:31 p.m. UTC | #2
On Thu, 2015-01-29 at 13:18 -0800, Eric Dumazet wrote:
> On Wed, 2015-01-28 at 05:57 -0800, Eric Dumazet wrote:
> > From: Eric Dumazet <edumazet@google.com>
> > 
> > RST packets and ACK packets sent on behalf of TIME_WAIT sockets
> > do not have a socket owner currently.
> ...
> > 
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > ---
> 
> Please do not apply.
> 
> I forgot about commit 3a7c384ffd57ef5fbd95f48edaa2ca4eb3d9f2ee
> ("ipv4: tcp: unicast_sock should not land outside of TCP stack")
> 
> I need to do this in another way.

Well, no, patch was fine, sorry for the noise.

I have to addresss ipv4 side.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 29, 2015, 10:16 p.m. UTC | #3
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 29 Jan 2015 13:18:59 -0800

> On Wed, 2015-01-28 at 05:57 -0800, Eric Dumazet wrote:
>> From: Eric Dumazet <edumazet@google.com>
>> 
>> RST packets and ACK packets sent on behalf of TIME_WAIT sockets
>> do not have a socket owner currently.
> ...
>> 
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
>> ---
> 
> Please do not apply.

Ok.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5d46832c6f72b89a278a3326918a3c8bff9afed4..cd4f7be3ecdd3628b07eb76bd2d4204753da23a6 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -809,12 +809,11 @@  static void tcp_v6_send_response(struct sock *sk, struct sk_buff *skb, u32 seq,
 		tot_len += TCPOLEN_MD5SIG_ALIGNED;
 #endif
 
-	buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,
-			 GFP_ATOMIC);
-	if (buff == NULL)
+	buff = sock_wmalloc(ctl_sk, MAX_TCP_HEADER, 1, GFP_ATOMIC);
+	if (!buff)
 		return;
 
-	skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len);
+	skb_reserve(buff, MAX_TCP_HEADER);
 
 	t1 = (struct tcphdr *) skb_push(buff, tot_len);
 	skb_reset_transport_header(buff);