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 D6C45EB64DD for ; Wed, 21 Jun 2023 18:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbjFUSr6 (ORCPT ); Wed, 21 Jun 2023 14:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbjFUSry (ORCPT ); Wed, 21 Jun 2023 14:47:54 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7079B; Wed, 21 Jun 2023 11:47:52 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qC2ri-0001Xx-27; Wed, 21 Jun 2023 20:47:38 +0200 Date: Wed, 21 Jun 2023 20:47:38 +0200 From: Florian Westphal To: Florent Revest Cc: Florian Westphal , Pablo Neira Ayuso , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kadlec@netfilter.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, lirongqing@baidu.com, daniel@iogearbox.net, ast@kernel.org, kpsingh@kernel.org, stable@vger.kernel.org Subject: Re: [PATCH nf] netfilter: conntrack: Avoid nf_ct_helper_hash uses after free Message-ID: <20230621184738.GG24035@breakpoint.cc> References: <20230615152918.3484699-1-revest@chromium.org> <20230621111454.GB24035@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Florent Revest wrote: > > in this case an initcall is failing and I think panic is preferrable > > to a kernel that behaves like NF_CONNTRACK_FTP=n. > > In that case, it seems like what you'd want is > nf_conntrack_standalone_init() to BUG() instead of returning an error > then ? (so you'd never get to NF_CONNTRACK_FTP or any other if > nf_conntrack failed to initialize) If this is the prefered behavior, > then sure, why not. > > > AFAICS this problem is specific to NF_CONNTRACK_FTP=y > > (or any other helper module, for that matter). > > Even with NF_CONNTRACK_FTP=m, the initialization failure in > nf_conntrack_standalone_init() still happens. Therefore, the helper > hashtable gets freed and when the nf_conntrack_ftp.ko module gets > insmod-ed, it calls nf_conntrack_helpers_register() and this still > causes a use-after-free. Can you send a v2 with a slightly reworded changelog? It should mention that one needs NF_CONNTRACK=y, so that when the failure happens during the initcall (as oposed to module insertion), nf_conntrack_helpers_register() can fail cleanly without followup splat? Thanks.