Netdev List
 help / color / mirror / Atom feed
* [PATCH net v5 0/2] net: openvswitch: fix a feature leak on a failed change
@ 2026-11-18  6:54 Minxi Hou
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Minxi Hou @ 2026-11-18  6:54 UTC (permalink / raw)
  To: netdev
  Cc: Aaron Conole, Eelco Chaudron, Ilya Maximets, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Shuah Khan, linux-kselftest, stable, Minxi Hou

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-18  6:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  6:54 [PATCH net v5 0/2] net: openvswitch: fix a feature leak on a failed change Minxi Hou
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox