netdev
[Top] [All Lists]

Re: [NETLINK] Fix multicast bind/autobind race

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: Re: [NETLINK] Fix multicast bind/autobind race
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 15 Mar 2005 18:19:09 +1100
Cc: netdev@xxxxxxxxxxx
In-reply-to: <20050314212845.6a7fd240.davem@davemloft.net>
References: <20050314094420.GA15349@gondor.apana.org.au> <20050314212845.6a7fd240.davem@davemloft.net>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
On Mon, Mar 14, 2005 at 09:28:45PM -0800, David S. Miller wrote:
> 
> I suspect a 2.4.x version is necessary as well.  Could you cook
> one up for me?  Thanks.

Sure, here it is.
 
netlink_autobind has always set nlk_sk(sk)->groups to zero.  This is
unnecessary because sk_alloc already zeroes the entire structure.
Since a socket can only be bound once netlink_autobind doesn't need
to zero groups at all.

This had been safe until I added mc_list.  Now it is possible for
netlink_bind to race against netlink_autobind running on the same
socket on another CPU.  The result would be a socket that's on
mc_list with groups set to zero.  This socket will be left on the
list even after it is destroyed.

The fix is to remove the zeroing in netlink_autobind.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Attachment: p
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>