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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1272469924.2267.80.camel@edumazet-laptop>
Date:	Wed, 28 Apr 2010 17:52:04 +0200
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Brian Bloniarz <bmb@...enacr.com>
Cc:	David Miller <davem@...emloft.net>, therbert@...gle.com,
	netdev@...r.kernel.org, rick.jones2@...com
Subject: Re: [PATCH net-next-2.6] net: sk_add_backlog() take rmem_alloc
 into account

Le mercredi 28 avril 2010 à 11:41 -0400, Brian Bloniarz a écrit :

> >  
> > +/*
> > + * Take into account size of receive queue and backlog queue
> > + */
> > +static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb)
> > +{
> > +	unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc);
> > +
> > +	return qsize + skb->truesize > sk->sk_rcvbuf;
> > +}
> > +
> 
> Reading sk_backlog.len without the socket lock held seems to
> contradict the comment in sock.h:
>   *	@sk_backlog: always used with the per-socket spinlock held
>   ...
> struct sock {
> 
>         ...
> 	/*
> 	 * The backlog queue is special, it is always used with
> 	 * the per-socket spinlock held and requires low latency
> 	 * access. Therefore we special case it's implementation.
> 	 */
> 	struct { ... } sk_backlog;
> 
> Is this just a doc mismatch or does sk_backlog.len need to use
> atomic_read & atomic_set?
> 

I'll submit a doc cleanup, and will avoid this 32bit hole in a reorg of
struct sock layout.

We read 'sk_backlog.len'  without lock to have a hint. We could have a
false positive only when queue is full, so this is not a big deal.

Then, after locking, we call sk_rcvqueues_full() once again.

Thanks for reviewing !


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