🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12723

[PATCH net v2 1/2] net: openvswitch: do not record user features when the change fails

#12723
From: Minxi Hou
Date: Sun, 08 Nov 2026 12:34
84 lines
14822 bytes
ovs_dp_change() stores the new features in dp->user_features before it
updates the per-cpu upcall port IDs, and that update fails when the
per-cpu-pids attribute is empty or its length is not a multiple of four.
The request returns -EINVAL with the new features already recorded.

The features decide whether the tc skb extension static key is enabled,
but the code that enables or disables the key runs after the failing
call, so it does not run for the failed request. dp->user_features then
claims TC_RECIRC_SHARING is set while tc_skb_ext_tc_enable() was not
called, and a later request that clears the bit calls
tc_skb_ext_tc_disable() for an enable that never happened.

tc_skb_ext_tc is one static key for the whole host. cls_flower, the
bridge, the flow dissector and OVS hold references to it, and the key
stays on while any of them holds one. The count ends up one short and
reaches zero while other users still hold a reference, so recirc sharing
in every datapath goes off with it, as does the skb extension allocation
in tc, in the flow dissector and in the bridge. A disable on a count of
zero also reaches the imbalance check in static_key_dec_not_one() in
kernel/jump_label.c and warns there, which panics a host that runs with
panic_on_warn. The opposite ordering is possible as well: a failing
request that drops the bit leaves the key enabled for good.

The request only needs CAP_NET_ADMIN, which a user namespace that owns a
network namespace provides. datapath_policy has no entry for
OVS_DP_ATTR_PER_CPU_PIDS and the operation skips strict validation, so an
empty attribute reaches the check that fails.

Keep the new features in the local variable until the request has gone
through, and use that variable for the enable and disable decisions. A
failed OVS_DP_CMD_SET then leaves both the features and the key alone.

Two other paths touch the bit without keeping the key in step:
ovs_dp_reset_user_features() clears it without disabling the key, and a
new datapath that fails after ovs_dp_change() succeeded is freed without
disabling it. Both predate this change and are left alone here, so a
failed OVS_DP_CMD_NEW and the reset that follows it still leave the key
one enable ahead.

The selftest in the next patch sends a set request that fails on an
empty per-cpu-pids and reads the features back; it fails without this
change and passes with it. The openvswitch selftest suite passes with
the change applied.

Fixes: 35d39fecbc24 ("net/sched: Enable tc skb ext allocation on chain miss only when needed")
Cc: stable@vger.kernel.org
Signed-off-by: Minxi Hou <houminxi@gmail.com>
---
 net/openvswitch/datapath.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index b2a0b09fd4a5..00043aef2d03 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1801,9 +1801,7 @@ static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])
 			return err;
 	}
 
-	dp->user_features = user_features;
-
-	if (dp->user_features & OVS_DP_F_DISPATCH_UPCALL_PER_CPU &&
+	if (user_features & OVS_DP_F_DISPATCH_UPCALL_PER_CPU &&
 	    a[OVS_DP_ATTR_PER_CPU_PIDS]) {
 		/* Upcall Netlink Port IDs have been updated */
 		err = ovs_dp_set_upcall_portids(dp,
@@ -1812,10 +1810,12 @@ static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])
 			return err;
 	}
 
-	if ((dp->user_features & OVS_DP_F_TC_RECIRC_SHARING) &&
+	dp->user_features = user_features;
+
+	if ((user_features & OVS_DP_F_TC_RECIRC_SHARING) &&
 	    !(old_features & OVS_DP_F_TC_RECIRC_SHARING))
 		tc_skb_ext_tc_enable();
-	else if (!(dp->user_features & OVS_DP_F_TC_RECIRC_SHARING) &&
+	else if (!(user_features & OVS_DP_F_TC_RECIRC_SHARING) &&
 		 (old_features & OVS_DP_F_TC_RECIRC_SHARING))
 		tc_skb_ext_tc_disable();
 
-- 
2.56.0
Technical Details
Message-ID: <20261108123424.2825403-2-houminxi@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358713-linux-kernel-netdev=dewy.ru
References: <20261108123424.2825403-1-houminxi@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358713-linux-kernel-netdev=dewy.ru
From: houminxi@gmail.com (Minxi Hou)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 1/2] net: openvswitch: do not record user features when the change fails
Date: Sun,  8 Nov 2026 07:34:23 -0500
Organization: Usenet Network
Message-ID: <20261108123424.2825403-2-houminxi@gmail.com>
References: <20261108123424.2825403-1-houminxi@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="122246"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QPUq07JDRB7mEdoW4GUJOJuU5GM= sha256:0IlD1XTtSaT2OjuJUt4s7M11Y7DrSTPXaO3zjH4oJcA=
	sha1:Hj0Iy5Vrct2kc+4LPNHYo1xAB4I= sha256:Xlg2OlCGmlkvtagAExoAS+Klu5trijmCPUWVKgfEYy8=
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 58EAA113571; Sun,  8 Nov 2026 15:35:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
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 tJ2j1XRApNd3;
	Sun,  8 Nov 2026 15:35:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358713-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 7D7321130BC; Sun,  8 Nov 2026 15:34:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id E17A2468CB; Sun,  8 Nov 2026 12:34:53 +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=1794141293;
	b=x4xNaiyhbOKPw6Xd/ZMx+04CnBPndHCyJZRkcDlkR6zxrvG8byCrVYshLCa9Yqp4B/1w
	 wHjAdXGhBNahN1XKzdnvYmt4UtWdnqo4VMPr7FRrRhjbxtm/WpR0FB9Apibe5kc0zCd8w
	 bTqTmdqHfJta/Mag8GkTcoSpdHbU7BiLpPOG7rv8w+XsZEXdgtSMLd+m0US6wBzNFzra+
	 kwG4IeYxDWfFCmbej9av05TLYi/62aAsc7Jyr4suY4C1zYNuWZWvSibmCHeBmbOAY77rT
	 yz+du5qzUqVXfchl3dGJM7VmLHKyth9oRnPYZcdEJVY/0h/N5CvmTaPVz1df4EzbXJw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794141293;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=a7MU1a2Ky80ww1QI8pf11DKI/bl0yAkVUnac57Jert8=;
	b=vZg3GGMI20V20iBokO2/0ZPM2bXKcbxcuFyYg9OzgjUWsxgFGEBQWvzp/kd7BZ2Y6qbY
	 OcG/SZslPO7OZTr1dloelsENkOa1BlRz+TjooyLVAr1K8s22nAu9PFOkG7sFhKmQ5uyRB
	 F2NRSzqPCm4QXor63vK3eAzpcHA8Ru5YH3m8iJQxhyamrqw2EZSu0ThFm/YQJLwFKYUXQ
	 zmQ8ISsBlJ/6NSnDaDqCfdeg1NZeXZsO2mhe+FU+iVR8IUqHQXyLh7HjR1DvJSvttVKzz
	 v3XzKRyxTK1rUCa5hGGltTITCww7BCRRA6YfhyQaGXEAKEoTDbt3Q+ksDRozCjWJ+/w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="lL7e/eKv";
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	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 54F16606A336;
	Sun,  8 Nov 2026 12:34:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lL7e/eKv
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.177
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794141292;
	b=FmZ285JgIsi7uGVfyQ5z0GCyegiqVozFOmxF1WDS/uqxDeToHniciC/L2eHd7i1aQ7mO
	 J/39SM+NTSwh6t6fHOpPWztcWG/2iNvKldJueWvqouwhGr5mdcmMvGE1OAC5VKBN4LmXJ
	 tCrPWJqIAOSAPQUU1WVhX4IirTJRpaVHvxOh6pm1NGKuGWZ9+hViynGLcP9RhOfRhyOkD
	 lHmu4+9OBjZegXIjZuSy8EtrNLdyzApMjqCLLSPxOaPYgMi/az16orjmO+rH0D/agc6Ud
	 OhofP2skD5p7F1camOfZ9NnRd6X+cYpG0vuCE/RCN55JeBImi8d3a++9ls4C34xoA4Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794141292;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=a7MU1a2Ky80ww1QI8pf11DKI/bl0yAkVUnac57Jert8=;
	b=DYlF/qQMVo7Reb13wgxhCay3Ogswa14lIYc5Qqf0HV1mHgqnMBtvq1dHiSSdYiETbUl3
	 zexWg0EEM53JtZ1q1GRN9gSWYWBcxU22D8LXRKxtWIESMibXART65ZU2xeANw2BOL4CGP
	 kbl3Fl4L5iQn6/D4F9WOvcyJPSZJce0Cpcop3QfcQBOVQ6HgdbKCeR7E4hYs1AgOCKk/N
	 XCLodKQmBFcu6E3eC8TEIF+v1OXi0679RRFdXaHm/mXbLfLO+HKNhMCZRm6VrOBkgAAzW
	 YumHJfvjwFlJfVdvx+TDHjJhwJ9zgA4DJ4CA011ElFPBGYVwzAUcP+8GtG0uOeksOVw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="lL7e/eKv";
	arc=none smtp.remote-ip=209.85.128.177
X-Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE076606A321
	for <netdev@vger.kernel.org>; Sun,  8 Nov 2026 12:34:51 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AE076606A321
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-8b309147589so422367b3.1
        for <netdev@vger.kernel.org>; Sun, 08 Nov 2026 04:34:51 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794141291; x=1794746091; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=a7MU1a2Ky80ww1QI8pf11DKI/bl0yAkVUnac57Jert8=;
        b=lL7e/eKvADhid0J2196uNo2gIgCkBKVN7yGBuZaGVHtWPcYH9FPAsY4DOVpPQY5NsN
         MM58r43vbHi9h8jguF/cIzzvvvEmr54uTt9JEIyoRg4o082BGgVYCQmaPI+YI9CBpjok
         5LYvmNo2oKcbziYmCw/R7ru2eEURLTyaqrFdmvKBCcBiMTCPGie7nZFzMsVRPyoH1q2e
         O97ArGsaIBbdzW11J3hvERUPv96noLm2dWDrXjKfd9DrB1+8EA/eJDd0tjRwIJFIKdZv
         XB8qlM7EB7lHZ7NAW0oM7i3ytu4AkD2OIzCjNrxuf7wT51YZNldaSaTvWU8uPyDBd85q
         Sntg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794141291; x=1794746091;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=a7MU1a2Ky80ww1QI8pf11DKI/bl0yAkVUnac57Jert8=;
        b=xCcnDt0ijoBbNwxKhlYWDXEVpbSSv8ib4uxugAoUISB6mRW3m/wQqGzyTIvolrHnFQ
         5yVg77qzWjLiS/ttIqBtpnaAcnj+xK4QmW5OLIo64xxUaBhVIffUITdARqSD2HJOJmSj
         4gmFFlzhCt0yCRSEds6BvFCLcQgFQMHkCcjl8f3w18s3la8BYVfMT4m+tLxdL5S3ZiSo
         j/0mNvIqjtLRW9QHPmJqAgq79Aw3Rn8GA3A6896Evd/f02ZJnDFpbGo1o2eufpptBm+Z
         x/u1vRHFm/oj0xjiiSxe9dJJOCVfww51frSgPWCeYz7+3ur1wtG4/7j3kmkAmP6r4Qpc
         OUNg==
X-Gm-Message-State: APuU4Z+WkSK+8FY85+KuO7jYs7PPlllfZfd+JQMkjmSp/V1Bjr7FVtX8
	kz3wL8GSm8EccXDYmk5RmXBKelFdqy4QS9DNGamZ3w4N4mOXSX05e3Ma64IDAnzC
X-Gm-Gg: AYBFou2W1ehh7+/28VhC4OGxHRy0NFbdu+AYCUm4pI6ldOuTCv39QBn8dg2BVyFUtK0
	jmKfvR1+fdU5zNZEM5GDJ3ZynGf4PNkXatsE9LWZGC1agQvb4aNZB3rrYH3wVI6skR3nD4u9afm
	4utMMVbP+Ui8OKnv/7UPAnLdqp2n0ojPoquzFVzbUzXi/SIbtqnjcuP1Oadmc1fNAFqwxp/pvdH
	5Th0GzFKzhtdAsVoSKyW8BwYE2smsYqVnRooUFospDpotIRGJnprNnaH+3fQLhvl3c16STcwhXS
	YHr54FUoYzJa6xtRMXLNyzyFQjtbZoe1JkbTw5FcxcO67W2LQLKcep6/MI513SVt+RvMl9kWcX9
	QPdD9/aqNXgfvBaKddqwBFlOqgNbSkrzAtJt5GOnDx54d6Q586Cj8W0elbH/QNqSaWEB/pdJQMS
	dk8OKR7RF1FUuQnmSNeXyMqVbJxtrgDPBThIQQu5z6mKlPJ8M4Wr831WWBGqWE9vL1D7JH2Ia/L
	RXQY0N8oNoE0UJYlDeknjSiT9tiAoLvnb9Botxwli/3txkNFNsuKcUQSvUUekKu/rZC48XDG5ID
	CJA4wEwWQ7a2+bMeUyuEvigg
X-Received: by 2002:a05:690c:83:b0:8b3:2e4f:6bfb with SMTP id 00721157ae682-8b36c9bcc9emr9231857b3.22.1794141290587;
        Sun, 08 Nov 2026 04:34:50 -0800 (PST)
X-Received: from houminxi ([61.170.225.237])
        by smtp.gmail.com with ESMTPSA id 00721157ae682-8b36be7d88dsm13475627b3.39.2026.11.08.04.34.44
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sun, 08 Nov 2026 04:34:49 -0800 (PST)
X-Cc: Aaron Conole <aconole@redhat.com>,
	Eelco Chaudron <echaudro@redhat.com>,
	Ilya Maximets <i.maximets@ovn.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Shuah Khan <shuah@kernel.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Paul Blakey <paulb@nvidia.com>,
	dev@openvswitch.org,
	linux-kselftest@vger.kernel.org,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261108123424.2825403-1-houminxi@gmail.com>
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