ovs_dp_change() records the requested features in dp->user_features before it updates the per-cpu upcall port IDs, and that update fails with -EINVAL when the per-cpu-pids attribute is empty or its length is not a multiple of four. The request fails with the new features already recorded, while the code that takes the reference for TC_RECIRC_SHARING never ran, so a later request that clears the bit drops a reference that was never taken.
The first two patches are the fix, split so that the single read of dp->user_features in queue_userspace_packet() stands on its own: it closes a separate and older oops and carries its own Fixes: tag. The third patch adds the selftest. The series is three patches; v5 had two. v6: - Split the single read of dp->user_features out of the fix. It closes a crash that aea0bb4f8ee5 introduced in 2014, and folding it into a patch whose Fixes: tag points at 35d39fecbc24 hid that from a stable backport. Link: https://lore.kernel.org/netdev/[email protected]/ - Move Fixes: and Cc: into the trailer block; they had prose below them. - Read the field with READ_ONCE() in ovs_dp_set_user_features(), now that every write to it is a single WRITE_ONCE(), and clear only the recirc bit through one helper instead of repeating the mask at two sites. - Carry a changelog per patch in the notes under ---, as Matthieu asked. - Quote the variables the new selftest helpers pass to subprocesses, and name both conditions that make the kernel reject the per-cpu-pids attribute. - Move Reported-by: to the kernel fix, with the link to the report. v5: https://lore.kernel.org/netdev/[email protected]/ - Use an empty per-cpu-pids attribute to make the update fail, instead of relying on the masks cache path. Suggested by Matthieu Baerts. - Report the datapath that cannot be read as that, and not as a feature mismatch. v4: https://lore.kernel.org/netdev/[email protected]/ - Take and drop the reference in one setter, and call it from every path that changes or clears the recirc bit, including ovs_dp_reset_user_features() and __dp_destroy(). - Clear only the recirc bit in __dp_destroy(), so an upcall that is reading the other bits keeps seeing them. v3: https://lore.kernel.org/netdev/[email protected]/ - Describe the user namespace path in the commit message. - Check the feature bit and the reference count in the selftest instead of only the return value. v2: https://lore.kernel.org/netdev/[email protected]/ - Split the selftest into its own patch. - Add the ovs-dpctl set-dp command the selftest needs. Signed-off-by: Minxi Hou <[email protected]> Minxi Hou (3): net: openvswitch: read the datapath features once when sending an upcall 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 | 70 +++++-- net/openvswitch/datapath.h | 7 +- .../testing/selftests/net/openvswitch/config | 3 + .../selftests/net/openvswitch/openvswitch.sh | 195 ++++++++++++++++++ .../selftests/net/openvswitch/ovs-dpctl.py | 74 +++++++ 5 files changed, 331 insertions(+), 18 deletions(-) base-commit: 2a324a58a084c5cfd7e5a2f55e0786bee170a4a5 -- 2.56.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
