From: Minxi Hou <houminxi@gmail.com>
To: netdev@vger.kernel.org
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>,
linux-kselftest@vger.kernel.org, stable@vger.kernel.org,
Minxi Hou <houminxi@gmail.com>
Subject: [PATCH net v5 0/2] net: openvswitch: fix a feature leak on a failed change
Date: Wed, 18 Nov 2026 01:54:33 -0500 [thread overview]
Message-ID: <20261118065435.2367014-1-houminxi@gmail.com> (raw)
ovs_dp_change() records the requested user features before it calls the
update that can fail, so a request rejected for an empty per-cpu-pids
leaves the datapath claiming a feature it never enabled. The tc skb
extension key is a reference count shared with cls_flower, and the code
that would keep it in step is skipped on that path.
Patch 1 fixes the ordering, and drops the reference on the two other
paths that take one and never give it back. Patch 2 adds a set-dp
command to the openvswitch selftest tool, and two tests that send such a
request and check the features the datapath reports afterwards. They
fail without the fix and pass with it.
The problem turned up while the YNL spec for this family was being
written: describing the ovs_datapath set command meant reading
ovs_dp_change(), where the ordering stands out.
v5:
- Rebased onto current net.
- The two teardown paths clear only OVS_DP_F_TC_RECIRC_SHARING, so a
datapath on its way out keeps the bits an upcall in flight still reads.
A whole-field store clears OVS_DP_F_UNALIGNED between the two reads in
queue_userspace_packet() and pad_packet() (reported by Sashiko).
- queue_userspace_packet() reads the features once and gives that value
to pad_packet(), so OVS_DP_CMD_SET cannot split the head room decision
from the padding decision either.
- The tests write their diagnostics to stderr, the skip message
included. A copy of stdout stayed open in the daemons the suite
starts, which kept the kselftest runner reading a pipe that never
reached EOF, so the run hung after the last subtest (reported by
Matthieu Baerts).
- A datapath that cannot be read, and one that reports no features, are
told apart and reported as such instead of as a feature mismatch, and
a failed expectation carries its own description.
- checkpatch reports nothing for either patch.
v4: https://lore.kernel.org/netdev/20261115163134.3202677-1-houminxi@gmail.com/
- Rebased onto current main, the tests say why they failed, and a
datapath that cannot be read is no longer reported as a feature
mismatch.
v3: https://lore.kernel.org/netdev/20261110174651.972936-1-houminxi@gmail.com/
- Cover the recirc bit as well as the dispatch bit.
v2: https://lore.kernel.org/netdev/20261108123424.2825403-1-houminxi@gmail.com/
- Name the two paths that leaked a reference and fix both.
v1: https://lore.kernel.org/netdev/20261107113403.797779-1-houminxi@gmail.com/
Neither leak has a test of its own. The reference count behind the bit is
not visible from user space, so the tests read back the features a
datapath reports: the reset drops them to zero where a test can see it,
and a datapath freed after a failed creation leaves no state to check.
The alignment race has no test either, because it needs a set or a
destroy to land between two reads of the field on another CPU, which a
functional test cannot schedule; the patch removes the second read
instead.
One thing this series leaves alone: ovs_add_dp() returns the status of the
last command in its body rather than of the add, so the "|| return 1" that
follows its calls cannot fail. That predates this series and every OVS
test that uses it.
Signed-off-by: Minxi Hou <houminxi@gmail.com>
Minxi Hou (2):
net: openvswitch: do not record user features when the change fails
selftests/net/openvswitch: check that a failed set keeps the features
net/openvswitch/datapath.c | 58 ++++--
net/openvswitch/datapath.h | 7 +-
.../testing/selftests/net/openvswitch/config | 3 +
.../selftests/net/openvswitch/openvswitch.sh | 195 ++++++++++++++++++
.../selftests/net/openvswitch/ovs-dpctl.py | 65 ++++++
5 files changed, 310 insertions(+), 18 deletions(-)
base-commit: 2a324a58a084c5cfd7e5a2f55e0786bee170a4a5
--
2.56.1
next reply other threads:[~2026-11-18 6:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 6:54 Minxi Hou [this message]
2026-11-18 6:54 ` [PATCH net v5 1/2] net: openvswitch: do not record user features when the change fails Minxi Hou
2026-11-18 6:54 ` [PATCH net v5 2/2] selftests/net/openvswitch: check that a failed set keeps the features Minxi Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118065435.2367014-1-houminxi@gmail.com \
--to=houminxi@gmail.com \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=echaudro@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox