From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E4C339D6E8 for ; Thu, 2 Apr 2026 12:06:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.96.220.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775131583; cv=none; b=bWZgqEm4QDZIXmNOeaaIAes3keajn7t0lfcsaO2FnSxAoZKrS5UPAOQ9uzbJvyWzYIYAddryMbKNaRgVqHfk0FxDk4q0SynrouIOxby3IV0NTzVI5H8rCkEuk0Tk+TiADWKSQmKFzlLcq/xFVTHPYCN2SAnvKeYvXnNrkqyBeqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775131583; c=relaxed/simple; bh=wTKOVE172x33ogTJ488J+DHu8qmeu2NG6PA4znno9y0=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UQF6cnEsMPnV6zTjq3VUd99KWRKXJ2R01UQEIRH10Q5pN58wAJ9VIVzrjWhGPOkvvKfUaxJHU3FVfsKkXyRYbhcKgql/uC2OGFYkYHPeExKPwRKqTHxHiaPLsG7uiKMNAeqoqTa3bc4BdFYHfEFXrFoyB/iPgVwjHLCb2d450xo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b=tsIlGj1/; arc=none smtp.client-ip=62.96.220.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b="tsIlGj1/" Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 338E1206DF; Thu, 2 Apr 2026 14:06:19 +0200 (CEST) X-Virus-Scanned: by secunet Received: from mx1.secunet.com ([127.0.0.1]) by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yabjBDPZlw0K; Thu, 2 Apr 2026 14:06:18 +0200 (CEST) Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.secunet.com (Postfix) with ESMTPS id 7AD9F20853; Thu, 2 Apr 2026 14:06:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 7AD9F20853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1775131578; bh=ESjNUTCU1GHV8myfhu3YwiadCFGWjJyYODhCZ3IAYno=; h=Date:From:To:CC:Subject:References:In-Reply-To:From; b=tsIlGj1/xzLw8TVQttl+eiFQcmcewwacJ2adgi0t24dcpQr4z4cyT2WD8JC3rdWzf RlLNcnIeyp9C+yxCW7QZWtXsdcGhbpnZNeZphA+5LJ/1qyCCy1JYDjxhmdWynsyKE8 xnY+Q+RSjvlil2Rnr0mqVD8IpPcToXPM1ezoPGeYSj9g4i/SmNBHxTTeG0eWkHOq3q BFmECBIACNpuoTFMtJnuRhq6d7WT7Ly2Q+hfk5cRxvz92E/mD90J16yA9yM3mZ1+pa C8oKTSs5112nFai1ehhW+FCpFE1YVBOA9z1JMiukREozDVTs0xuqO/V2pFZkOaf3vz MsO1OZF2/5LmA== Received: from secunet.com (10.182.7.193) by EXCH-01.secunet.de (10.32.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 2 Apr 2026 14:06:18 +0200 Received: (nullmailer pid 3819456 invoked by uid 1000); Thu, 02 Apr 2026 12:06:17 -0000 Date: Thu, 2 Apr 2026 14:06:17 +0200 From: Steffen Klassert To: Florian Westphal CC: Subject: Re: [PATCH ipsec 2/2] xfrm: Wait for RCU readers during state netns exit Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de (10.32.0.171) On Thu, Apr 02, 2026 at 01:57:37PM +0200, Florian Westphal wrote: > Steffen Klassert wrote: > > xfrm_state_fini() flushes the resize and GC work, destroys all states, and > > then frees the state hash tables and the inbound percpu state cache. > > Those objects can still be observed by concurrent RCU readers. We need > > to wait for a RCU grace period before freeing the hash tables and the > > percpu cache to avoid netns teardown racing with lockless lookups. > > > > Fix this by adding synchronize_rcu() before freeing the state hash > > tables and the inbound percpu state cache. > > > > Fixes: c8406998b801 ("xfrm: state: use rcu_deref and assign_pointer helpers") > > Signed-off-by: Steffen Klassert > > --- > > net/xfrm/xfrm_state.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c > > index 1748d374abca..84fbf1591138 100644 > > --- a/net/xfrm/xfrm_state.c > > +++ b/net/xfrm/xfrm_state.c > > @@ -3327,6 +3327,8 @@ void xfrm_state_fini(struct net *net) > > xfrm_state_flush(net, 0, false); > > flush_work(&xfrm_state_gc_work); > > > > + synchronize_rcu(); > > + > > xfrm_state_flush() is expected to relink all states to the gc list for > the gc worker to handle. > > The xfrm state worker calls synchronize_rcu() and then frees states > on the state gc list. Yes, xfrm_state_gc_task() does the synchronize_rcu() already. I found the ploicy thing and had the impression we need it here as well. I'll skip this one out. Thanks!