Re: [PATCH] net: xfrm: fix a race condition during allocing spi

From: Herbert Xu
Date: Thu Oct 22 2020 - 02:48:27 EST


On Thu, Oct 22, 2020 at 01:53:15PM +0800, zhuoliang.zhang wrote:
>
> there are 2 related hash lists : net->xfrm.state_bydst and
> net->xfrm.state_byspi:
>
> 1. a new state x is alloced in xfrm_state_alloc() and added into the
> bydst hlist in __find_acq_core() on the LHS;
> 2. on the RHS, state_hash_work thread travels the old bydst and tranfers
> every xfrm_state (include x) to the new bydst hlist and new byspi hlist;
> 3. user thread on the LHS gets the lock and adds x to the new byspi
> hlist again.

Good catch. Please add a Fixes header. I think this was introduced
with the dynamic resizing in f034b5d4efdfe0fb9e2a1ce1d95fa7914f24de49.

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