From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59D15C388F2 for ; Thu, 22 Oct 2020 06:48:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F35D2463D for ; Thu, 22 Oct 2020 06:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504343AbgJVGs0 (ORCPT ); Thu, 22 Oct 2020 02:48:26 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:37144 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440717AbgJVGsZ (ORCPT ); Thu, 22 Oct 2020 02:48:25 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1kVUON-00077a-V1; Thu, 22 Oct 2020 17:48:09 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 22 Oct 2020 17:48:07 +1100 Date: Thu, 22 Oct 2020 17:48:07 +1100 From: Herbert Xu To: "zhuoliang.zhang" Cc: Steffen Klassert , "David S . Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com Subject: Re: [PATCH] net: xfrm: fix a race condition during allocing spi Message-ID: <20201022064807.GA16043@gondor.apana.org.au> References: <20201020081800.29454-1-zhuoliang.zhang@mediatek.com> <20201021071222.GA11474@gondor.apana.org.au> <1603345995.13237.2.camel@mbjsdccf07> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1603345995.13237.2.camel@mbjsdccf07> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt