Article View: linux.kernel.netdev
Article #16141Re: [PATCH net-next 09/15] netfilter: flowtable: purge entries immediately when destroying the flowtable
From: netdev-bot+sashiko
Date: Sat, 14 Nov 2026 03:23
Date: Sat, 14 Nov 2026 03:23
71 lines
10952 bytes
10952 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates the impact of the bug it fixes.
--
netfilter: flowtable: purge entries immediately when destroying the flowtable
When a flowtable is destroyed, this patch stops relying on the hardware
offload workqueue to purge the remaining flow entries. It now walks the
rhashtable through rhashtable_free_and_destroy() with
nf_flow_table_do_purge(). That callback tears down each flow, removes its
hardware state synchronously and frees it. NF_FLOW_PENDING marks the first
tuplehash visited, so the flow is released only on the second visit.
> Do not use hardware offload workqueue to purge the remaining flow
> entries when the flowtable is being destroyed. Instead, iterate over the
> flowtable to purge the remaining flow offload entries. Work memory
> allocations can fail, leaving us with either waiting indefinitely until
> work can be allocated or leaving entries in the hardware.
[Severity: Low]
The code change looks correct. Does this paragraph understate what the old
nf_flow_table_free() sequence could do when the work allocation failed?
The old sequence was:
nf_flow_table_iterate(flow_table, nf_flow_table_do_cleanup, NULL);
nf_flow_table_gc_run(flow_table);
nf_flow_table_offload_flush_cleanup(flow_table);
rhashtable_destroy(&flow_table->rhashtable);
On that path, nf_flow_offload_gc_step() calls nf_flow_offload_del(). If the
GFP_ATOMIC allocation in nf_flow_offload_work_alloc() fails, it returns
before setting NF_FLOW_HW_DYING:
offload = nf_flow_offload_work_alloc(flowtable, flow, FLOW_CLS_DESTROY);
if (!offload)
return;
set_bit(NF_FLOW_HW_DYING, &flow->flags);
As a result, flow_offload_del() is never called for that flow, and it stays
in the rhashtable. rhashtable_destroy() frees only the bucket tables. That
leaks the struct flow_offload along with its nf_conn reference and its
route dst references, which goes beyond leaving entries in the hardware.
The allocation could also fail in the first nf_flow_table_gc_run() and then
succeed in the second one, inside nf_flow_table_offload_flush_cleanup():
flush_workqueue(nf_flow_offload_del_wq);
nf_flow_table_gc_run(flowtable);
In that case, the del work is queued after the last flush and never flushed
again. nf_tables_flowtable_destroy() calls kfree(flowtable) right after
nf_flow_table_free() returns, and tcf_ct_flow_table_cleanup_work() frees
ct_ft. So when the work runs later, flow_offload_work_handler() would read
offload->flowtable->net, and flow_offload_tuple_del() would walk
offload->flowtable->flow_block.cb_list, both in freed memory.
Could the commit message mention the flow and conntrack reference leak, and
the possible use-after-free of the flowtable from late-queued del work?
That would help stable and security triage assess this fix.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113031251.2437074-2-pablo%40netfilter.org
Technical Details
Message-ID:
<179462662793.2199510.7483926977653221306@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363073-linux-kernel-netdev=dewy.ruReferences:
<20261113031251.2437074-10-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363073-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 09/15] netfilter: flowtable: purge entries immediately when destroying the flowtable Date: Sat, 14 Nov 2026 03:23:47 +0000 Organization: Usenet Network Message-ID: <179462662793.2199510.7483926977653221306@kernel.org> References: <20261113031251.2437074-10-pablo@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1499758"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:/1A4GFOoO5q2FVzk8pmdC2kH7qw= sha256:6FqSfh/SlxAZ9ZQAXUFxSDgkgIwJLB8QCFHnSKn+dP0= sha1:cS7HYY3lGLeqIRCBXExrn/tsiEw= sha256:zzFxUQhfubA9Qr8eZ4q5RfNMi86XifMGDl74w50wQ14= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D67C3114756; Sat, 14 Nov 2026 06:24:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 97zXQU2KeHbx; Sat, 14 Nov 2026 06:24:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-363073-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 23119114753; Sat, 14 Nov 2026 06:24:30 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 413DD607859; Sat, 14 Nov 2026 03:24:15 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794626630; b=Dh9VTcGMO6HOIF5gcL8482xCo2U/HlyLNizybXAshz046w6Vkk/a9LU+F7t4KgGaLKxM QtbrA/ffbpis1uUd5kWStomFTt2/dgTIZqjn45wLqQDAuvdZ5pmAU+sH1abPs0VGusMk7 bVJod+1BMve8l5fjgYssTtErspCJy6datkajVmrPN/moGuvyzxz42MRZX4piLerJxYGXp UusVg1NWCpjtLppWuCU331DflrporkIhwHvhdVpjD7B1EVUdg+0lbR4ib7Ah2oQLnBbSs CDqQLPRYfhGnpzPo3ajapQBsWpm08ArtDFdx6kHPv0eQ+WG65hJc765OcXNF0+rvR2g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794626630; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=EOVBelVsv2I8YL97UAGEhvodlQG6Qp9F9pQ9y48RuQg=; b=jXO2TxVb2aiGfkV+Myam/pWh27Ywwsg5sv4XbLuM/isPsCtiUEyaJ3RVTyPPZUeVVNob xK1AtviPEU1LPmhSVxCZhRv7OXtNTdBYVLNAtyNmlm3am+4CFgID00DZFHmcWe4YiRa2k HYJc50cLKRvrhTnUNks+NDb/MzJVOQolp8QB/s/77Zv4zjcwNqHv5D8PSVPCDbnWTNgJ9 rv1v0cjZwDZGknVe0iSEj+pE/+0HBSqiZxjyskK0q5jeBHkoFuMGzwIG8KJ6YBbbAK9s2 I5viBMb36w5ED5YIkY2x1db8zYK89aqpIOyeOxJcXCd72g8tu3FZVaZSCxTJVSakD2Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RnUVkQB5; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1118D606A33D; Sat, 14 Nov 2026 03:23:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RnUVkQB5 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794626629; b=3G82pkLFzBpBSGWonPn2Pzsy+b5YC5nY9yCcVNhF3iYagtVbP70W0Xt0oYzKAl4226Wu ai9Oac2le8BBqP/PLYNY1o294r5kdgquQbOvFRJKOOwNTx+VlO9BOpqpi8ZmvqGqBVRRx HzppYJ3ob/Dae6qIE7dgf1HvsiZp9K+yo/0m8AhmuoyTSDugoPX4eH02QFrpK5ufItBp0 VjJfoPQtGYRi88ORICmiYoYEtJri+ViDdeIfwp8PDZKSwaRygnWtTwcbC/5hY0L81vauX W9ZrF+s5t7e/y/syEBqaFSvEbc2uoWlmcJWpHdSO2IqZCvvjSh8eepAg9I1mSoEsIdg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794626629; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=EOVBelVsv2I8YL97UAGEhvodlQG6Qp9F9pQ9y48RuQg=; b=sAXxrDHQIiXQMj+N72imI3C/bxGa85LrlBcIVhmGQRuw38FwsC//PYxrjq9jh3IOFoA6 ClnGy8kTc9irjD5tQYCzmbmyKtBrIrPWB2y8eQ9DLFipS9cCqkV3wiqnYv37KrDsmn0vB YuMxHhGU2F5XJHooT1xFpHjZBr4jwvUGOHZNp5ZdrN9MwqpCLdnqr7Wpej+pSHd18SwH8 GFOOj6Ss3gE+M0ZASwuULXyarJH6LSmKtwKUfkgw92l/7rosKYmcoz4A3svwCJM2ivt/S PG8BbOQG0cWIyr00KdFi/bU0ectF1zBNpSNP8I1LofzzQ+UVTaRU3XBTxLBJa94nz6Q== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RnUVkQB5; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 311D460A2610; Sat, 14 Nov 2026 03:23:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F7EE1F000C4; Sat, 14 Nov 2026 03:23:48 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794626628; bh=EOVBelVsv2I8YL97UAGEhvodlQG6Qp9F9pQ9y48RuQg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=RnUVkQB54I5nSPX0pbVQqkKQONuiAbjju/g/YfM0g/qgn4LksKlx/h3IX96enS5Fh dvixDVMgB3+zbPHhvDmtWIsUHuMLye8V1oRRbdVHtVQ3isX4M2PQ8u77dOWFpovwRh WSrQTiallZSaKgejk7l4qJDcfruhhbHlF5LWNVAtCEHitcsj2AYor3ZB1jd61VtYXR UwKK1q2REh51Au6obsJqLAh7YQ66t1O2T3GOyUyHkLZWorW6Tmbt9AKFi2bn/A72zw f9E02YiLK1N1aIem+pJtgpyzvmsy9vhXYMW5/eEVFmV61vfMdEq+eGgGaIsqCVqfvb ZmNjjDpiU0mrQ== X-Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-In-Reply-To: <20261113031251.2437074-10-pablo@netfilter.org> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list