Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795020906; b=NcgW3XcCyYaRFaFJeEx4gLyV4iY4IdjAboFrQ5GKI3cb5Ox6K3A5qLiIEnMg7pW1zpHr GdASwPAIwJNFkg2Xk+EJIYttRHaEHzK3vZq2JIcbDKTRcNFZ3gi5zODf+jPd9PHMYSDZF e2aASkXCETmUc0at2w8YZHOpJRbRIDqQUM18/LE6/TcnOymMvr8CKdhNzXjDu7vY3IjSy /i5Or2lC2apEAjaguVZmyOsgkwVw0SgrbLX53VtiKjOYw+il05Ofbjm9VxLhkS2Ds+KlV ba+Gmx40wZgamWQjBtZohm4c5HdKv/J/Bl2Vy/PKZbNdqq3m6L3YVAaEe+F01Spf0yw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795020906; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=oZGhUNs+dGCsCXxSVDHl9ghD3D2INw7jryazB/Jf+j8=; b=dGT+XNu+/JlXENgSjTpxvHuHHbojbbeLiKPRY1wGV/xu1u0gnBakbLemRLaemOCSRG+L omyOmWthhdnEEsU+uXWsLZJeMQXQnLz2j5fuHjtz3/K9ECIVSrDnVAWyl3yoZlt+f2FGL JYgt9gzG0XE7jM1+egQtyhewzWjyWIAQ5CqVv2yusdIlUvApqdL/Oh/dYG8I/wyk8qCzo s5+TMEHMdlM7TaVR9Oz+htiDhZCNCMPkkbh3S5C6iugT9pwH5WSnMot6IZ74dQQvi4eaU 0aGUHP0Xo9V8mg6dW4aLGfB+Pr7/H+4bZKuLa099cOyKYBNnXggfdCeYJB1hS1toT7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=taTwmf7f; arc=none smtp.remote-ip=100.103.45.18 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 729A0606B584; Wed, 18 Nov 2026 16:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=taTwmf7f Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A76E1F000C4; Wed, 18 Nov 2026 16:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795020906; bh=oZGhUNs+dGCsCXxSVDHl9ghD3D2INw7jryazB/Jf+j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=taTwmf7f5oiRjgOnizaYXE1dJirn+ZzI9v3akdQVPlJ+1cqjimGherb5n8g/Gytrc f0AOCep0V+IildcC8g30/QkTzc+s0PuznRnukGGjQKwM4Lu2ccQ2T37yDGNOw/lRsb kLehsZFdKHt2bJJLg8CXcfBDvzb/uH+kCrnxf8Bo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 7.3 2118/2651] netfilter: conntrack: fix unlikely UaF in gc worker Date: Wed, 18 Nov 2026 15:55:58 +0100 Message-ID: <20261118150402.183518482@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit 9836164821a46af07428bb2a5e14137bf0c7bd6e ] When early-drop scan is enabled, gc_worker() reads tmp->ct_net, resolves cnet with nf_ct_pernet(), and reads cnet->count with RCU read lock held but before acquiring a reference to tmp. Its unlikely but possible that the worker gets preempted before reading cnet->count while nf_conntrack_cleanup_net_list manages to unlink all conntracks and returns in the mean time. This allows for the pernet memory to get free'd. On resume, use after free would occur when the worker reads cnet->count. This can be solved either via another synchronize_rcu() in nf_conntrack_cleanup_net_list or via cheaper flush_work(). If work wasn't running no race can happen as next call cannot observe already-unlinked conntrack objects. This is an LLM finding with no reproducer, but it appears to be correct. Fixes: c6dd940b1f74 ("netfilter: allow early drop of assured conntracks") Reported-by: Vega Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index d0d9e5ea84a09..6cba999e80561 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -2507,6 +2507,11 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list) goto i_see_dead_people; } + /* must wait for current scan loop, worker also looks at + * struct nf_conntrack_net, which is about to be free'd. + */ + flush_work(&conntrack_gc_work.dwork.work); + list_for_each_entry(net, net_exit_list, exit_list) { warn_on_keymap_list_leak(net); nf_conntrack_ecache_pernet_fini(net); -- 2.53.0