Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1117109pxv; Thu, 1 Jul 2021 17:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4yfndhoGSeW1kO+0lyYH5jgTuAraUYsOJfIFClvk0CikFRn8mFqXFeLy+sKWet1VxjxwU X-Received: by 2002:a50:ff0a:: with SMTP id a10mr3327282edu.273.1625187486658; Thu, 01 Jul 2021 17:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625187486; cv=none; d=google.com; s=arc-20160816; b=AddC5PMhqujnrNGnSiDN4sGWwJlGyAsxX0aLMh+MkfBkt9E4m7TjqJUE/zhZyV1kFC Iwjl3mvYYGG46JFISWSFYH7kattxdxjoMpgnkw63upIqcY5MZA2+Ax2FXCa6rPdPWcdx Va8SRGtNWnRhEB1QVnSenFgTFnl/pLShd9vx2DJot4qJFLupMh9xxCP605cks7ebwMxu F1a0mEYILKt/sjt4nb7+MGicSVpWEJQIOU1k1TSblAfNz10G/03mu9A0RqQVB10jwybv T6ERLMUOEkxAvMu2jwTFunSb8C4JMvAuyBbtgwSJ7MICadw8hMDIehbSmhAg0I73pQ7z LcDg== 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=oIG0oV2o+zqcw97wNURmnCaj1Y2/L0Uwo5uJcKIs6Qo=; b=M4eGj5GhzH3lQES0D/2xcIlOuvzfWfijNpHG/j2NYqjxTZ5Hrng3AfBo9YggitsrZ9 8hx2BLkJYpA7iREYRXxNqYaSydTcdk5U9SPVOMER+0QK/4UfoCNYIzAVf8u0U7LUd5wV NTWIIXMlkwxTecA07BG26FG+SrPHBxga4vbyTmZRBa1gQSpUc/5pLbJRbYTWuvR9PxFQ 4pFq5My4pCOW9wuEc0s2H438KuTxb/soWtIaOqzuV1DCzgYS+PgNAqKJe9ZklN50sDjp AcpJiTcpGj6NBtfOruLS69aJZksz96OkgLE/anMM0uavwPBJUXclfqXj634LK8QvkUug Qf5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si1492964edd.151.2021.07.01.17.57.43; Thu, 01 Jul 2021 17:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234547AbhGBA7C (ORCPT + 99 others); Thu, 1 Jul 2021 20:59:02 -0400 Received: from mail.netfilter.org ([217.70.188.207]:41992 "EHLO mail.netfilter.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbhGBA7B (ORCPT ); Thu, 1 Jul 2021 20:59:01 -0400 Received: from netfilter.org (unknown [90.77.255.23]) by mail.netfilter.org (Postfix) with ESMTPSA id A781A60705; Fri, 2 Jul 2021 02:56:22 +0200 (CEST) Date: Fri, 2 Jul 2021 02:56:26 +0200 From: Pablo Neira Ayuso To: Vasily Averin Cc: Jozsef Kadlecsik , Florian Westphal , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH NETFILTER v2] netfilter: gre: nf_ct_gre_keymap_flush() removal Message-ID: <20210702005626.GB29227@salvia> References: <0e3cdbe6-33f7-60b0-64ca-72f6f6a42df8@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0e3cdbe6-33f7-60b0-64ca-72f6f6a42df8@virtuozzo.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 01, 2021 at 08:02:24AM +0300, Vasily Averin wrote: > nf_ct_gre_keymap_flush() is useless. > It is called from nf_conntrack_cleanup_net_list() only and tries to remove > nf_ct_gre_keymap entries from pernet gre keymap list. Though: > a) at this point the list should already be empty, all its entries were > deleted during the conntracks cleanup, because > nf_conntrack_cleanup_net_list() executes nf_ct_iterate_cleanup(kill_all) > before nf_conntrack_proto_pernet_fini(): > nf_conntrack_cleanup_net_list > +- nf_ct_iterate_cleanup > | nf_ct_put > | nf_conntrack_put > | nf_conntrack_destroy > | destroy_conntrack > | destroy_gre_conntrack > | nf_ct_gre_keymap_destroy > `- nf_conntrack_proto_pernet_fini > nf_ct_gre_keymap_flush > > b) Let's say we find that the keymap list is not empty. This means netns > still has a conntrack associated with gre, in which case we should not free > its memory, because this will lead to a double free and related crashes. > However I doubt it could have gone unnoticed for years, obviously > this does not happen in real life. So I think we can remove > both nf_ct_gre_keymap_flush() and nf_conntrack_proto_pernet_fini(). Also applied. I think nf_ct_gre_keymap_flush() became useless when the GRE was de-modularized (built-in into nf_conntrack).