Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1004421pxv; Fri, 25 Jun 2021 03:21:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqyq/5Pm5iRCVpEeBt1f1QRO/uNKd5qkuy6csz854Z7CtzuMBpW1jhj5+r/epaIK7m/Rk2 X-Received: by 2002:a02:7348:: with SMTP id a8mr8791541jae.116.1624616508896; Fri, 25 Jun 2021 03:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624616508; cv=none; d=google.com; s=arc-20160816; b=GS1zqaog0jlxW4r1Syv0MJk+6Puzpt1bXo95YWfCjcGjmnakl9rzgS/Q9csiA75k8C veqiypLPTK+IFR4H1GO6NcRhvP+4ABO5c0qmASc9ukGuucr4mHkxHw0LKd4kFAZDJVJu gy94e2K6dDv8RxaVohQ5A4t/gMAIvR4MS+pZrFLJSJaqhDe29g1up4M2RAXxyfnWAPTE t3jWqbWrRE34VEWheOoXfJjchTOQFtpeFSdlUdyeY+yqUQX7o7BNfB2EWgLAlDb0YLyR G95Nbg1aZz/uP0SFk8zE+CDczs2nE4OKeJZHdQr7B0Z9d9dh9wsvLOiJQtqAkHDT8Nzl s1Ag== 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=HyzHzZi/7NG6cCLJxLxCFdZcPLvd6BlGhB/nsPYx0U8=; b=uMtUR23nC92MRgS/L3lN+cHyKwXbxO0OeTxSTISm4RlgGWOXZorAtWsHcxKSQMXBZY 3wESN3IA1rg0XPkE62Hne/bKycwe6fD24rPC2WIcxle64vIa/tmYF/bbg21tCeUFZJn6 OMtrzizFGIRuS1UeLXdxR+mvxj96c/7SA+8kQ3suLL0snkzcWjIoB/ylwaSP8EiU2j2Z zjAQ1zz06wUJ6ZtIskb1S5oO7PVQhn/JQ2wqiZyIY52JaZQ7uX8ra+8xJW8yCosFkX9d QwuZatKuTEe/B9QkbEWFGpsUkLYEP/v1fXQ0JHRYj7046i8B0zHikUWre+tj4lTU8iA+ mKfQ== 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 x5si7977522ilu.1.2021.06.25.03.21.36; Fri, 25 Jun 2021 03:21:48 -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 S231390AbhFYKWw (ORCPT + 99 others); Fri, 25 Jun 2021 06:22:52 -0400 Received: from mail.netfilter.org ([217.70.188.207]:51280 "EHLO mail.netfilter.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbhFYKWs (ORCPT ); Fri, 25 Jun 2021 06:22:48 -0400 Received: from netfilter.org (unknown [90.77.255.23]) by mail.netfilter.org (Postfix) with ESMTPSA id 86567607EB; Fri, 25 Jun 2021 12:20:24 +0200 (CEST) Date: Fri, 25 Jun 2021 12:20:21 +0200 From: Pablo Neira Ayuso To: Dan Carpenter Cc: Colin King , Jozsef Kadlecsik , Florian Westphal , "David S . Miller" , Jakub Kicinski , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] netfilter: nf_tables: Fix dereference of null pointer flow Message-ID: <20210625102021.GA32352@salvia> References: <20210624195718.170796-1-colin.king@canonical.com> <20210625095901.GH2040@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210625095901.GH2040@kadam> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Jun 25, 2021 at 12:59:01PM +0300, Dan Carpenter wrote: > Btw, why is there no clean up if nft_table_validate() fails? See below. > net/netfilter/nf_tables_api.c > 3432 list_add_tail_rcu(&rule->list, &old_rule->list); > 3433 else > 3434 list_add_rcu(&rule->list, &chain->rules); > 3435 } > 3436 } > 3437 kvfree(expr_info); > 3438 chain->use++; > 3439 > 3440 if (flow) > 3441 nft_trans_flow_rule(trans) = flow; > 3442 > 3443 if (nft_net->validate_state == NFT_VALIDATE_DO) > 3444 return nft_table_validate(net, table); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > The cleanup for this would be quite involved unfortunately... Not > necessarily something to attempt without being able to test the code. At this stage, the transaction has been already registered in the list, and the nf_tables_abort() path takes care of undoing what has been updated in the preparation phase. Having said this, Colin patch is correct, it's fixing up the error path.