Re: rhashtable: Fix potential crash on destroy in rhashtable_shrink
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2015-01-31 11:22:14
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2015-01-31 11:22:14
On Sat, Jan 31, 2015 at 11:16:52AM +0000, Thomas Graf wrote:
On 01/31/15 at 08:36pm, Herbert Xu wrote:quoted
The current being_destroyed check in rhashtable_expand is not enough since if we start a shrinking process after freeing all elements in the table that's also going to crash.(The check in expand() is just an optimization to drop out of work cycles if it does not make sense to continue anymore.)quoted
This patch adds a being_destroyed check to the deferred worker thread so that we bail out as soon as we take the lock.Shouldn't the cancel_work_sync() in rhashtable_destroy() block until the deferred worker is done and cancelled?
That's too late. nft_hash will have freed all the elements before rhashtable_destroy gets called. 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