Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB094288C1E for ; Wed, 18 Jun 2025 11:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750244760; cv=none; b=iImsvdKO70/YPLXVkWpLvTyoXXyomFp/PzNDEIhWq7JvefhlX9usC/KkJ0RdTi30NVUKiSEzwgbDdN9y0aVYpkVN0trV1GKoaphSkU+MceH44IRtI+Ns3iHV1Njw1DisPTxbQSuZO3Gs31oWku7fyEmsUG+HNbmKKkgM4mnrwVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750244760; c=relaxed/simple; bh=2mdkDAAkOHrE4kpTmrA9VSNOCj/0jfrrcwwV+E1OUZ0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Zj6pdzqr8PCXBY4VDL1W1a6briHxxEq7hGUna921LGIitqMd38X87mASvkvaKl0/4yeQAWMJzG5ewNYQE+/DkiX56Xa7lCG2Et5PrCmGpduYYKK/BC6Nc8APOVUWJvNEPczSo2ElvapwRPcDEKCAdVvcjpw1M4t2kX/tZw1oZJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HFy2g8Va; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HFy2g8Va" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BB7AC4CEE7; Wed, 18 Jun 2025 11:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750244760; bh=2mdkDAAkOHrE4kpTmrA9VSNOCj/0jfrrcwwV+E1OUZ0=; h=From:To:Cc:Subject:Date:Reply-to:From; b=HFy2g8VaNdqrbwPpIh+44OZUF0yIuB0Af5v7ZAMdkJnXasZuclfGQ1qPfIiYQVde7 zw2tujlP1eFbMoZ1BBRmkHJ4UVZNuNo8P558xLPfIbQlc9jhr5l7+ZvgUobK+ieb5q Y4Hw1hadRV0IS/HK2Aicu4hLsxKrgSyEN6mIdZjM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50000: netfilter: flowtable: fix stuck flows on cleanup due to pending work Date: Wed, 18 Jun 2025 13:01:05 +0200 Message-ID: <2025061828-CVE-2022-50000-5753@gregkh> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4941; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=9Sl99bgdtp1P1MZeHxSk8uls3b1MigoPW9rhzPZVbKs=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlBc3wyDv2ve/zqcbTm7GyLxIdHFaLZPr/5JHV5xw7n3 duZ7q5e1hHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATKb7IML/OxObAC+cOU64H V5M7d3otuTxRaiLD/Pr9Dwtzsy/cXXnoq3Xyq55zb90aowE= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: netfilter: flowtable: fix stuck flows on cleanup due to pending work To clear the flow table on flow table free, the following sequence normally happens in order: 1) gc_step work is stopped to disable any further stats/del requests. 2) All flow table entries are set to teardown state. 3) Run gc_step which will queue HW del work for each flow table entry. 4) Waiting for the above del work to finish (flush). 5) Run gc_step again, deleting all entries from the flow table. 6) Flow table is freed. But if a flow table entry already has pending HW stats or HW add work step 3 will not queue HW del work (it will be skipped), step 4 will wait for the pending add/stats to finish, and step 5 will queue HW del work which might execute after freeing of the flow table. To fix the above, this patch flushes the pending work, then it sets the teardown flag to all flows in the flowtable and it forces a garbage collector run to queue work to remove the flows from hardware, then it flushes this new pending work and (finally) it forces another garbage collector run to remove the entry from the software flowtable. Stack trace: [47773.882335] BUG: KASAN: use-after-free in down_read+0x99/0x460 [47773.883634] Write of size 8 at addr ffff888103b45aa8 by task kworker/u20:6/543704 [47773.885634] CPU: 3 PID: 543704 Comm: kworker/u20:6 Not tainted 5.12.0-rc7+ #2 [47773.886745] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009) [47773.888438] Workqueue: nf_ft_offload_del flow_offload_work_handler [nf_flow_table] [47773.889727] Call Trace: [47773.890214] dump_stack+0xbb/0x107 [47773.890818] print_address_description.constprop.0+0x18/0x140 [47773.892990] kasan_report.cold+0x7c/0xd8 [47773.894459] kasan_check_range+0x145/0x1a0 [47773.895174] down_read+0x99/0x460 [47773.899706] nf_flow_offload_tuple+0x24f/0x3c0 [nf_flow_table] [47773.907137] flow_offload_work_handler+0x72d/0xbe0 [nf_flow_table] [47773.913372] process_one_work+0x8ac/0x14e0 [47773.921325] [47773.921325] Allocated by task 592159: [47773.922031] kasan_save_stack+0x1b/0x40 [47773.922730] __kasan_kmalloc+0x7a/0x90 [47773.923411] tcf_ct_flow_table_get+0x3cb/0x1230 [act_ct] [47773.924363] tcf_ct_init+0x71c/0x1156 [act_ct] [47773.925207] tcf_action_init_1+0x45b/0x700 [47773.925987] tcf_action_init+0x453/0x6b0 [47773.926692] tcf_exts_validate+0x3d0/0x600 [47773.927419] fl_change+0x757/0x4a51 [cls_flower] [47773.928227] tc_new_tfilter+0x89a/0x2070 [47773.936652] [47773.936652] Freed by task 543704: [47773.937303] kasan_save_stack+0x1b/0x40 [47773.938039] kasan_set_track+0x1c/0x30 [47773.938731] kasan_set_free_info+0x20/0x30 [47773.939467] __kasan_slab_free+0xe7/0x120 [47773.940194] slab_free_freelist_hook+0x86/0x190 [47773.941038] kfree+0xce/0x3a0 [47773.941644] tcf_ct_flow_table_cleanup_work Original patch description and stack trace by Paul Blakey. The Linux kernel CVE team has assigned CVE-2022-50000 to this issue. Affected and fixed versions =========================== Issue introduced in 5.5 with commit c29f74e0df7a02b8303bcdce93a7c0132d62577a and fixed in 5.15.64 with commit 8fbdec08dbf7d7ab8e35bdc65eb4394bc82d1e26 Issue introduced in 5.5 with commit c29f74e0df7a02b8303bcdce93a7c0132d62577a and fixed in 5.19.6 with commit 89e135a36a9eb81412b5459df94a80995ce62eef Issue introduced in 5.5 with commit c29f74e0df7a02b8303bcdce93a7c0132d62577a and fixed in 6.0 with commit 9afb4b27349a499483ae0134282cefd0c90f480f Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2022-50000 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: include/net/netfilter/nf_flow_table.h net/netfilter/nf_flow_table_core.c net/netfilter/nf_flow_table_offload.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/8fbdec08dbf7d7ab8e35bdc65eb4394bc82d1e26 https://git.kernel.org/stable/c/89e135a36a9eb81412b5459df94a80995ce62eef https://git.kernel.org/stable/c/9afb4b27349a499483ae0134282cefd0c90f480f