From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 71A6C4CEE6D for ; Wed, 16 Sep 2026 15:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789573285; cv=none; b=rxld999Wd9I/5jvLI1VQnOlR4Vai1t13J48v3z5naqr/bFJSVEcWvR7u9M512JsqPh7e9YwbQY17v/O8bSAxUpQ3sdQlWK8D5/j2KMJhhmVfAwQ3B/X23gffyzSvmEiCDFewW6F5RsJ4S7/pBvcApSEIX7nM+lUbiZvy25H4tr8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789573285; c=relaxed/simple; bh=VTxvGzLS5E4t4M1yItwz4g0pngokJp/MkT2E0zUy69I=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=fb+yoiXCSg7ab5VXygtEfzkLGtQQGGayIN6qqMW8ZkRI5b8AVqxMxrgOeNK4vU8KJ/mMu5xBYPi60AE/t587tM3sYQXdkagCOfJHSIIowUT9QQGgN2fXfVB3vS62GQfZDheWDoNHJUa1B2TevAwhVmxm29dGlPcIVY4WmQfGupk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kv2CjpMY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kv2CjpMY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C59B21F000FF; Wed, 16 Sep 2026 15:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789573282; bh=WdnbNsmhiyvc9+FYkJFtZ2TPQLbXxhf+7q/pAOkryog=; h=Subject:To:Cc:From:Date; b=kv2CjpMYhRujQvRgrj/eEeq0PvDnnSYFz4zF5JftyDemK0QhDVgy+9j/Vm0JIhRf5 zQr4if6TqRE9iA/GVWJny4ZMNQcY85JTMuUAMMkQNApPMQ6rJP3jjsi6FVOQY51tvm yubrCz4+t74KP28sIrHEaC/VI/rzslhpbyaBnmBE= Subject: FAILED: patch "[PATCH] netfilter: cttimeout: prevent UAF during module unload" failed to apply to 6.18-stable tree To: nicoyip.dev@gmail.com,pablo@netfilter.org Cc: From: Date: Wed, 16 Sep 2026 16:32:39 +0100 Message-ID: <2026091639-unmade-pouch-5365@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x fec9b1de0d02de8dafa3cc344bcb91cf28660643 # git commit -s git send-email --to '' --in-reply-to '2026091639-unmade-pouch-5365@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From fec9b1de0d02de8dafa3cc344bcb91cf28660643 Mon Sep 17 00:00:00 2001 From: Chengfeng Ye Date: Mon, 24 Aug 2026 20:12:38 +0800 Subject: [PATCH] netfilter: cttimeout: prevent UAF during module unload nf_ct_set_timeout() protects the timeout hook dereference and policy lookup with rcu_read_lock(). cttimeout_exit(), however, unregisters the per-net operations before it clears the hook. This allows the following interleaving: CPU 0 CPU 1 cttimeout_exit() nf_ct_set_timeout() unregister_pernet_subsys() rcu_read_lock() kfree(pernet) h = nf_ct_timeout_hook h->timeout_find_get() nfct_timeout_pernet() The hook still points to ctnl_timeout_find_get() when CPU 1 looks up the already freed per-net timeout list. KASAN reported: BUG: KASAN: slab-use-after-free in ctnl_timeout_find_get Read of size 8 by task poc/90 Call Trace: ctnl_timeout_find_get+0x271/0x2a0 [nfnetlink_cttimeout] nf_ct_set_timeout+0x7b/0x3c0 xt_ct_tg_check+0x724/0xb20 xt_check_target+0x234/0xa90 do_ipt_set_ctl+0x570/0x1270 Allocated by task 89: __kmalloc_noprof+0x16e/0x460 ops_init+0x6d/0x420 register_pernet_operations+0x2f6/0x670 Freed by task 91: kfree+0x131/0x390 ops_undo_list+0x3d4/0x730 unregister_pernet_operations+0x232/0x490 unregister_pernet_subsys+0x1c/0x30 cttimeout_exit+0x52/0x970 [nfnetlink_cttimeout] Clear the hook and wait for existing readers before unregistering the per-net operations. This blocks new policy lookups and ensures readers that observed the hook finish before the per-net storage is freed. Fixes: ebfbe67568a7 ("netfilter: cttimeout: use net_generic infra") Cc: stable@vger.kernel.org Signed-off-by: Chengfeng Ye Signed-off-by: Pablo Neira Ayuso diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index 66c2016f6049..132c02ac7c4e 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c @@ -652,9 +652,9 @@ static void __exit cttimeout_exit(void) { nfnetlink_subsys_unregister(&cttimeout_subsys); - unregister_pernet_subsys(&cttimeout_ops); RCU_INIT_POINTER(nf_ct_timeout_hook, NULL); synchronize_net(); + unregister_pernet_subsys(&cttimeout_ops); } module_init(cttimeout_init);