All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb
@ 2015-01-28 13:57 Eric Dumazet
  2015-01-29 21:18 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2015-01-28 13:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

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(-)

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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb
  2015-01-28 13:57 [PATCH net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb Eric Dumazet
@ 2015-01-29 21:18 ` Eric Dumazet
  2015-01-29 21:31   ` Eric Dumazet
  2015-01-29 22:16   ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2015-01-29 21:18 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb
  2015-01-29 21:18 ` Eric Dumazet
@ 2015-01-29 21:31   ` Eric Dumazet
  2015-01-29 22:16   ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2015-01-29 21:31 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb
  2015-01-29 21:18 ` Eric Dumazet
  2015-01-29 21:31   ` Eric Dumazet
@ 2015-01-29 22:16   ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-01-29 22:16 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-29 22:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28 13:57 [PATCH net-next] ipv6: tcp: tcp_v6_send_response() should give an owner to skb Eric Dumazet
2015-01-29 21:18 ` Eric Dumazet
2015-01-29 21:31   ` Eric Dumazet
2015-01-29 22:16   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.