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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA77EC433EF for ; Wed, 23 Mar 2022 13:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244275AbiCWNYd (ORCPT ); Wed, 23 Mar 2022 09:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244263AbiCWNYd (ORCPT ); Wed, 23 Mar 2022 09:24:33 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABA11BCB3 for ; Wed, 23 Mar 2022 06:23:02 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1nX0x3-00016X-3h; Wed, 23 Mar 2022 14:23:01 +0100 From: Florian Westphal To: Cc: Florian Westphal Subject: [PATCH nf-next v3 13/16] netfilter: cttimeout: decouple unlink and free on netns destruction Date: Wed, 23 Mar 2022 14:22:11 +0100 Message-Id: <20220323132214.6700-14-fw@strlen.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220323132214.6700-1-fw@strlen.de> References: <20220323132214.6700-1-fw@strlen.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Increment the extid on module removal; this makes sure that even in extreme cases any old uncofirmed entry that happened to be kept e.g. on nfnetlink_queue list will not trip over a stale timeout reference. Signed-off-by: Florian Westphal --- net/netfilter/nfnetlink_cttimeout.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index 49fe2ec40af9..5d49fbeabd86 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c @@ -657,12 +657,24 @@ static int __init cttimeout_init(void) return ret; } +static int untimeout(struct nf_conn *ct, void *timeout) +{ + struct nf_conn_timeout *timeout_ext = nf_ct_timeout_find(ct); + + if (timeout_ext) + RCU_INIT_POINTER(timeout_ext->timeout, NULL); + + return 0; +} + static void __exit cttimeout_exit(void) { nfnetlink_subsys_unregister(&cttimeout_subsys); unregister_pernet_subsys(&cttimeout_ops); RCU_INIT_POINTER(nf_ct_timeout_hook, NULL); + + nf_ct_iterate_destroy(untimeout, NULL); synchronize_rcu(); } -- 2.34.1