Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4287819pxt; Wed, 11 Aug 2021 02:26:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6zx1zdxJPYywcrcK/Nxo0JPZMZVYc5Ifg1HOmSL1JHGmWWznv0i/5o0UixZybXLO5QTrs X-Received: by 2002:a17:906:2755:: with SMTP id a21mr2695739ejd.488.1628673972012; Wed, 11 Aug 2021 02:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628673972; cv=none; d=google.com; s=arc-20160816; b=iOQeuljzAAbariUfzyAiWjOLox3CzX3BPkYajrT61Qn21P5JyDm8Gt4VwiEHaLhSSZ zeyABVDPnOYsJHOqz6CBwt98/Tcum6pMygLIEQYl/hC0KYKKYq7Mx9AN3AnqUhRWLwg1 hI0jsgH44WcZd6bRG0S1p0CkugLzIvP8yBqiDR8oo2JE4fCwNX0ZYksP/Ju6jXoXQfTx Lq3aBBeEuiiKnUX/DV2RWfrQthOAwPiRikwRSez+Ynsxze7PHMINnyHynUA+eubwLwoA b8qPgHn/GGnMryfOdeCuzC8STSDy056wnBHIoOMVHxZnd89vF7MxOiyv04vVw4/BO6wX HGtA== 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=TelckjHutNkEZPvWbdtwEuEnYH4fEi6q5RQBnzqzdww=; b=wmzyRVX38ipy5ckZtS4ComuqZ1zzmUZyMf0TZ5/d0w+C1nqXOmLGWrnZEl1w0D+G3o x6JCxrczh3pK4JbZGQa0DVj4xl52JbINYLsahO88LyqjHIvUIGY+8wx4CUKH4kD34Ug6 EX56QZGUafaz0aT9Lqa0Jb57RElqb1aDREIZSzFCPF8DAjO3E4e505do0lwMbedPh+il bgin6NifTrU2PEyXLRq4gYK8Bc+XgzLtTs4bmRKlhw6wzwNZs8Fz3qWyCd1qY+5mtZHc 0n9eW5YWI7uOLkhbwG48UX0l8NTUW2pNuGq/sBfBBMW1siZwQdZ9tIjqDZsWXZ1ss1dI lLDA== 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 r2si5141982edo.387.2021.08.11.02.25.48; Wed, 11 Aug 2021 02:26:11 -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 S236365AbhHKJWc (ORCPT + 99 others); Wed, 11 Aug 2021 05:22:32 -0400 Received: from mail.netfilter.org ([217.70.188.207]:44268 "EHLO mail.netfilter.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234670AbhHKJWc (ORCPT ); Wed, 11 Aug 2021 05:22:32 -0400 Received: from netfilter.org (bl11-146-165.dsl.telepac.pt [85.244.146.165]) by mail.netfilter.org (Postfix) with ESMTPSA id 4370560066; Wed, 11 Aug 2021 11:21:25 +0200 (CEST) Date: Wed, 11 Aug 2021 11:22:02 +0200 From: Pablo Neira Ayuso To: Pavel Skripkin Cc: kadlec@netfilter.org, fw@strlen.de, davem@davemloft.net, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+649e339fa6658ee623d3@syzkaller.appspotmail.com Subject: Re: [PATCH v2] netfilter: protect nft_ct_pcpu_template_refcnt with mutex Message-ID: <20210811092201.GA23996@salvia> References: <20210810125523.15312-1-paskripkin@gmail.com> <20210810125920.23187-1-paskripkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210810125920.23187-1-paskripkin@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 03:59:20PM +0300, Pavel Skripkin wrote: > Syzbot hit use-after-free in nf_tables_dump_sets. The problem was in > missing lock protection for nft_ct_pcpu_template_refcnt. > > Before commit f102d66b335a ("netfilter: nf_tables: use dedicated > mutex to guard transactions") all transactions were serialized by global > mutex, but then global mutex was changed to local per netnamespace > commit_mutex. > > This change causes use-after-free bug, when 2 netnamespaces concurently > changing nft_ct_pcpu_template_refcnt without proper locking. Fix it by > adding nft_ct_pcpu_mutex and protect all nft_ct_pcpu_template_refcnt > changes with it. Applied to nf.git, thanks