Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9815361rwd; Wed, 21 Jun 2023 12:14:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4luHWSozUzn5Y4fy2CJEj7vcFW3F/V/ZEYuHN/TZhTja0XfcBxt9jrF0ZDtAZwJGDZpNQk X-Received: by 2002:a54:4597:0:b0:39e:d0a4:d11f with SMTP id z23-20020a544597000000b0039ed0a4d11fmr8842920oib.30.1687374839818; Wed, 21 Jun 2023 12:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687374839; cv=none; d=google.com; s=arc-20160816; b=Lb7a5IJCxfdArNOYXWO2ung9dYx9gAxHvLVcLFxpCd/yQgoSvPaRgvf4a66VWBgxEf HO6zxgeRRRhwO9cYOqBYUcVy1u63nZ/UhGzfodMV62JAPyw8n0RJlIk9pJzX+c4n+UgU sw52h2BVvkAonWhxN9V0PoLMCbeUs1iHGPJp/F0KzktBCm2IcwpBUZYkilVx+nDGOr9f J8WXooQPF96t94ojvVSK5Fz1mOlB5VrxmTaiDPgyY8+BZ+nySISqaLAKrCva5ib58Crq f5o6f0p7+sW1JIb5nP2WjtG0HSeFwbFnHr0elfCOeg26wYUwYzQ46nP2s3kjj9cQzYiF l2KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YVNtHSha/1tcoH6RnK+P7JBhV8P8WokVXY0IYMfAkbQ=; b=u+mMHvdEH84+TvkzD2/V8qrGotMTZTlbQPSUJ7coiVs0GvM2zXbh9KjfQ4hU35PHya WE17jx1Tnwht/Rm4jXK/aTSCzsG+RDVywEWsNFmW3xPJd4Oqts6Z7Bx8Xtr3GQvX5WgE imkf4jlrVD1H56PjwnOvs2QiCbEGf1/LEtiU6xnwpudxn1qT4f1HsUn+6Mc7+3sMpkzo sl7mtwI62EqamDIEClfUsjy3Nyl1i0eLkQxqpPkCx7W1Con8/CymEAjJJ0XNNjdDgeRn xIOO8O9hTFkMH0iUVR708p9tceYNNjC/2S53fEx1TTL8485owr34zWstyN/GCvTco0Cw cACw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a17090a090f00b0025bedce8090si4735926pjn.65.2023.06.21.12.13.47; Wed, 21 Jun 2023 12:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231292AbjFUSr5 (ORCPT + 99 others); Wed, 21 Jun 2023 14:47:57 -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) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.