Re: netlink: Kill bogus lock_sock in netlink_insert
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2015-05-16 12:32:54
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2015-05-16 12:32:54
On Fri, May 15, 2015 at 01:02:19PM -0400, David Miller wrote:
Actually, Herbert, I think this lock_sock() is needed. Otherwise nothing protects nlk_sk(sk)->portid, upon which we perform a non-atomic test-and-set operation here. If you remove the lock_sock(), two parallel bind/inserts are possible on the same socket, potentially resulting in socket state corruption.
You're quite right. I forgot about that case. However, the code as is still buggy because it fails to reset portid when our auto-allocated portid collides with somebody else, resulting in a bogus bind failure. I'll fix that up too in a new patch. Cheers, -- Email: Herbert Xu [off-list ref] Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt