lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1413321018.17109.7.camel@edumazet-glaptop2.roam.corp.google.com>
Date:	Tue, 14 Oct 2014 14:10:18 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	David Miller <davem@...emloft.net>
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH net] tcp: TCP Small Queues and strange attractors

On Tue, 2014-10-14 at 15:33 -0400, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@...il.com>
> Date: Mon, 13 Oct 2014 06:27:47 -0700
> 
> > diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> > index 8d4eac793700..4a7e97811d71 100644
> > --- a/net/ipv4/tcp_output.c
> > +++ b/net/ipv4/tcp_output.c
> > @@ -839,26 +839,38 @@ void tcp_wfree(struct sk_buff *skb)
> >  {
>  ...
> >  		local_irq_restore(flags);
> > -	} else {
> > -		sock_wfree(skb);
> > +		return;
> >  	}
> > +out:
> > +	sk_free(sk);
> >  }
> >  
> 
> Why do we need to release the socket here?

Thats because we had to keep a reference at the very beginning :

+       /* Keep one reference on sk_wmem_alloc.
+        * Will be released by sk_free() from here or tcp_tasklet_func()
+        */
+       wmem = atomic_sub_return(skb->truesize - 1, &sk->sk_wmem_alloc);
+


If we find that we do not arm the tasklet (and keep the reference), we
then can remove the last ref we kept.

sk_free() is essentially doing :

if (atomic_dec_and_test(&sk->sk_wmem_alloc))
    __sk_free(sk)

sock_wfree() is the same, its only that we know that TCP socket do not
pass this test :

if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE)) {
   sk->sk_write_space(sk);
}






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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ