Re: [PATCH 4/8] rhashtable: fix race in nested_table_alloc()

From: Herbert Xu
Date: Sat May 05 2018 - 05:29:20 EST


On Fri, May 04, 2018 at 01:54:14PM +1000, NeilBrown wrote:
> If two threads run nested_table_alloc() at the same time
> they could both allocate a new table.
> Best case is that one of them will never be freed, leaking memory.
> Worst case is hat entry get stored there before it leaks,
> and the are lost from the table.
>
> So use cmpxchg to detect the race and free the unused table.
>
> Fixes: da20420f83ea ("rhashtable: Add nested tables")
> Cc: stable@xxxxxxxxxxxxxxx # 4.11+
> Signed-off-by: NeilBrown <neilb@xxxxxxxx>

What about the spinlock that's meant to be held around this
operation?

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt