Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3710263pxt; Tue, 10 Aug 2021 09:33:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCiCRsdaDDSMMKC47sx9kIzz+CXoE9E6643qG2e4PUiE3BtMh0j/CkYSaabgK4aMQx7TS3 X-Received: by 2002:a5e:d70a:: with SMTP id v10mr144561iom.81.1628613197938; Tue, 10 Aug 2021 09:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628613197; cv=none; d=google.com; s=arc-20160816; b=c4+YPb1L2Qtw6fMV8jQgu2qVJPuqFbZsYpaI8drSGNRTJszn+AN73rBIjzujAvkPsj Zn9Dh9x5GwDeSzV32E/PnRjPRyAQp/GBA5S1vvwt/EfAAJvUnqUqPKIQfuf/lOSgN1JA yhiaPOXoyKk10XormAQsLQM7Bz8Zx0k2qAyxJi7s7mGwc+hoAqspyyjRprCN1w2/4P32 zPz85tyo1a35bV1aifSjqq3Wg9Foq2nfcdrIVjc/4JcKcpXjBvoF88H0R796L5oZ4Oyq dhkYm1WLaG0oqZ7o+henhviWjuekouAf6SWplj6TpjPk9/ohxE0znacwnZP7tpbY+p+S c3Cg== 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=/L9oUzfCXIv2bJTwU6ul30SYTw6mfRf3rtmoj8xEKRU=; b=R3j/Kl0/i7lNH6BjwsR4QVG4y7CpLM/9piKOBdefoKc20e2zutnjNDL+MTfqwquM76 pgrSXQu8FGMkCYiIqPwLaSLDNdtUJNJ2IDwov+4QyoBC2W6Rc+VVYBLpMIn0E5y0hx0/ K4WNsgR7q4v6p8Ov4lzswqIVsydeyAKPbD+GvAaLyZ43QUiufNcvkSdGQXoBCJnb3Vz5 /PsF+6XQx5oTb++mZ/1EjdeSXpLtQ4eWHZbCZ6tUUKAZffpHxb0xjuEvPjr3cEAHgRIJ 50n0LRymouF/zIWoaENcbF3VrFOIM0H5t13onkb5cMEdLeoLW/ddyUnDzsLPaMJ2uyKX 0qjg== 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 y23si21295511jak.77.2021.08.10.09.33.07; Tue, 10 Aug 2021 09:33:17 -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 S241254AbhHJNXb (ORCPT + 99 others); Tue, 10 Aug 2021 09:23:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239580AbhHJNX2 (ORCPT ); Tue, 10 Aug 2021 09:23:28 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF30C0613D3; Tue, 10 Aug 2021 06:23:04 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1mDRiS-0008GT-E0; Tue, 10 Aug 2021 15:22:48 +0200 Date: Tue, 10 Aug 2021 15:22:48 +0200 From: Florian Westphal To: Pavel Skripkin Cc: pablo@netfilter.org, 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: <20210810132248.GS607@breakpoint.cc> References: <20210810125523.15312-1-paskripkin@gmail.com> <20210810125920.23187-1-paskripkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 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. > > Fixes: f102d66b335a ("netfilter: nf_tables: use dedicated mutex to guard transactions") > Reported-and-tested-by: syzbot+649e339fa6658ee623d3@syzkaller.appspotmail.com > Signed-off-by: Pavel Skripkin Acked-by: Florian Westphal