Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3390384ybb; Sun, 22 Mar 2020 23:30:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtJKLU1OAVOMJWtGieGJSubkb9isra2sRblz3qresEOyzE/HuWjg/pppT5a4xsap2ybm2pt X-Received: by 2002:a9d:2056:: with SMTP id n80mr10664960ota.281.1584945015626; Sun, 22 Mar 2020 23:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584945015; cv=none; d=google.com; s=arc-20160816; b=nY9/iB+wczR0x+rATmwPsBUfMmP1E0HNbJ/SS89Uutoqlft3USFq9B/fQ9CUMKnVnL 5C4nmH09u42tFUnwfa1V4MTLMlwPJ2yaas6Wg1F9kqNVvUZ4lfx1tqGwKcauXK1Phf9F 2kwgk/xTPe5/Q5RKSOC18ErYLA6yJRZL+or5ytO0UbbKwataaes/QRoFzWtfHHlNs149 5KzzoptfQ2/NnlJItNBVdXkDnyNlH3fGE9E8lWXfbw+ewUEWE61aTJz2yvQHkp/oRYQZ 1uw5FekKmQtyQOriOmBMo0jVxWEN3RyKTWYdJHhFeGJ04rkBYn9yNl/UnEGR7If7eiS4 J2CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mOu+LJ36tg75OQCcXcGy2gU0IQIYrdUkx7bXqA/jqy8=; b=mRAybWQUmKzLiJS653Emx1ZPHXKUfeq/YpODadqKDI8z13y60whkk834Oj+1K5/Ti5 6jjojlTtFjFJCTaHlO+qxwGpVNkTDbbETTgMDpNT4EOhQJiQgSs+lEX4vwSPxty8IGfp SBaiznEWdW/4W/qIihCMxZ7OD0nBJuf/k0wEwUGg47YqOCU2y1V1YQdZVJKEwyeRREnt GZ85XpRqQMn4H5cKIc4SDcvKZWkFiPygdlRpiB4pK33SUWOfQQ7KWLhj16YQwbIFsFWf egjCske419aqtX2LMqnCEI9sew+IvDwyd1uh/B53ArOnLmN49+H9w51Pt9D5xN0sx2pw 3iEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 26si7047925oiz.107.2020.03.22.23.30.03; Sun, 22 Mar 2020 23:30:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727297AbgCWG3p (ORCPT + 99 others); Mon, 23 Mar 2020 02:29:45 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:56914 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbgCWG3p (ORCPT ); Mon, 23 Mar 2020 02:29:45 -0400 Received: from gwarestrin.me.apana.org.au ([192.168.0.7] helo=gwarestrin.arnor.me.apana.org.au) by fornost.hmeau.com with smtp (Exim 4.89 #2 (Debian)) id 1jGGaI-0004Wx-IH; Mon, 23 Mar 2020 17:29:15 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Mon, 23 Mar 2020 17:29:14 +1100 Date: Mon, 23 Mar 2020 17:29:14 +1100 From: Herbert Xu To: YueHaibing Cc: steffen.klassert@secunet.com, davem@davemloft.net, kuba@kernel.org, timo.teras@iki.fi, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] xfrm: policy: Fix doulbe free in xfrm_policy_timer Message-ID: <20200323062914.GA5811@gondor.apana.org.au> References: <20200318034839.57996-1-yuehaibing@huawei.com> <20200323014155.56376-1-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200323014155.56376-1-yuehaibing@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 09:41:55AM +0800, YueHaibing wrote: > > diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c > index dbda08ec566e..ae0689174bbf 100644 > --- a/net/xfrm/xfrm_policy.c > +++ b/net/xfrm/xfrm_policy.c > @@ -434,6 +434,7 @@ EXPORT_SYMBOL(xfrm_policy_destroy); > > static void xfrm_policy_kill(struct xfrm_policy *policy) > { > + write_lock_bh(&policy->lock); > policy->walk.dead = 1; > > atomic_inc(&policy->genid); > @@ -445,6 +446,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy) > if (del_timer(&policy->timer)) > xfrm_pol_put(policy); > > + write_unlock_bh(&policy->lock); Why did you expand the critical section? Can't you just undo the patch in xfrm_policy_kill? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt