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 6FF39318B83 for ; Wed, 30 Sep 2026 00:44:03 +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=1790729044; cv=none; b=aF9VYRxYw+3sIiTlWHqRH4HJK8SUPGAlvNSaCuny/c0X6+cI6BHyHm/B56DZNJjHiIQ5RT9x8SwFrHvJu5YKX1Xq3zoMrbLgxdPXC2ygYRnt9Q5k1eunR5Sn1qMqcBs4a2iN369QhD2sjYLC5Cc6JJf0AVRyOIikBzlC3ZYOODk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790729044; c=relaxed/simple; bh=fThKKklkdHOT2G8oZuAnXAt8oPfrUsugqyaWPQkSHao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ESQtTNUWjKOVoYtbJsg702Pi8jDtCH2aa2ZX/sUS5UP4PiyV0YvrqfyRMq+v/U8eA9g2akMIUOtTZDixrb6XZDWIqO6sbNvrE3XHkrNm8GgpXxww7+gBLhVh+ZIko2BGro4cvF+0lPRZLNaiP9tQUCWw2bl1e4bCbENkmFNC7mQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eTCvnD9s; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eTCvnD9s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 636C51F000FF; Wed, 30 Sep 2026 00:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790729043; bh=d0/ZOXr9kbA1KNOeA645GrDJnuuYs26E+wuv3XGjx/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eTCvnD9sSs7LpacLb3thDWZtb3LlWy8l5s6KFCMp7Ipg6xDZgyf7AmIftiF+Vv4af A1nylQbZjWexCM33IT8P1i+LszhGFhkNq7deL2aWNMrQSxJp1ONZZ9HG0KRMZxJi7A pctOuI/zpMYdp3WiGRtZezzDWE5/o8AvXhSbilxwz2dnLvp3o6mEpboVyFOmnqJ7gc IT6gBceaevh9Tr4/6JGxn1+J74e8zYS8BQ+KwSR9UK5XJihK95qqR0dSWtn8pk86qx Rs5HHmqAQ+j//5MpPc72G07b9T4bWpOJ18B1howqaFl4kkeVms3QOI/krIUl2MnMhG 7H9qe9LOSCBzQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Ilya Maximets , Axel Mierczuk , Aaron Conole , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6.y 1/2] net: openvswitch: conntrack: avoid modifying shared unconfirmed ct entry Date: Tue, 29 Sep 2026 20:43:59 -0400 Message-ID: <20260930004400.2953232-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026092949-ceremony-whomever-76f9@gregkh> References: <2026092949-ceremony-whomever-76f9@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ilya Maximets [ Upstream commit 26b2bd70d22457556e2fa01cbf1192cb1a94d619 ] In a case where skb with an unconfirmed ct entry gets cloned, we may end up committing both but with different sets of extensions. The series of events: 1. The first clone wants to commit and runs the helpers wiring up the extension pointer into the expectation list. 2. Then it looses the confirmation keeping the entry unconfirmed. 3. Second clone now wants to commit labels and adds the new extension for that breaking the pointer in the expectation list causing UAF on the destruction path later. While this is possible to trigger, there should be no practical network pipeline where committing both clones without modifications into the same zone is needed. So, let's just reset the entry in case for some reason we got an skb with a shared one during commit. This doesn't affect any known use cases, but avoids any potential problems with sharing and modification of the unconfirmed ct entry. The fixes tag points to the introduction of helpers, since that's the main UAF trigger for the sharing. Fixes: cae3a2627520 ("openvswitch: Allow attaching helpers to ct action") Cc: stable@vger.kernel.org Reported-by: Axel Mierczuk Signed-off-by: Ilya Maximets Reviewed-by: Aaron Conole Link: https://patch.msgid.link/20260921145655.3167436-2-i.maximets@ovn.org Signed-off-by: Jakub Kicinski Stable-dep-of: dad19b59da05 ("net/sched: act_ct: fix helper UAF due to extensions realloc") Signed-off-by: Sasha Levin --- include/net/netfilter/nf_conntrack.h | 5 +++++ net/openvswitch/conntrack.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index a2c987289401e..3b41312cb0b02 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -190,6 +190,11 @@ static inline void nf_ct_put(struct nf_conn *ct) nf_ct_destroy(&ct->ct_general); } +static inline bool nf_ct_shared(const struct nf_conn *ct) +{ + return refcount_read(&ct->ct_general.use) > 1; +} + /* load module; enable/disable conntrack in this namespace */ int nf_ct_netns_get(struct net *net, u8 nfproto); void nf_ct_netns_put(struct net *net, u8 nfproto); diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 6ceec146e694f..ac8d19779d287 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -716,6 +716,18 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, enum ip_conntrack_info ctinfo; struct nf_conn *ct; + /* If the ct entry is not confirmed and shared with some other skb, + * e.g., a cloned one, we can't just modify it with the commit as we + * must not modify the extension set. Reset. + */ + if (cached && info->commit) { + ct = nf_ct_get(skb, &ctinfo); + if (ct && !nf_ct_is_confirmed(ct) && nf_ct_shared(ct)) { + nf_reset_ct(skb); + cached = false; + } + } + if (!cached) { struct nf_hook_state state = { .hook = NF_INET_PRE_ROUTING, -- 2.53.0