From: netdev-bot+sashiko@kernel.org
To: houminxi@gmail.com
Cc: netdev@vger.kernel.org, aconole@redhat.com, echaudro@redhat.com,
i.maximets@ovn.org, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v4 1/2] net: openvswitch: do not record user features when the change fails
Date: Mon, 16 Nov 2026 16:33:40 +0000 [thread overview]
Message-ID: <179484682026.3136.13753538826492049125@kernel.org> (raw)
In-Reply-To: <20261115163134.3202677-2-houminxi@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch changes __dp_destroy()
(net/openvswitch/datapath.c:1973) so that its first statement is…
--
net: openvswitch: do not record user features when the change fails
This patch moves the write of dp->user_features in ovs_dp_change() so it
happens after the per-cpu upcall portid update. It adds
ovs_dp_set_user_features(), which keeps the tc skb extension reference in
sync with the OVS_DP_F_TC_RECIRC_SHARING bit. The helper is then used from
ovs_dp_reset_user_features(), the ovs_dp_cmd_new() error path and
__dp_destroy().
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index b2a0b09fd4a56..8fcb9f2c8ece0 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -1704,6 +1704,20 @@ static struct datapath *lookup_datapath(struct net *net,
> return dp ? dp : ERR_PTR(-ENODEV);
> }
>
> +/* Called with ovs_mutex. */
> +static void ovs_dp_set_user_features(struct datapath *dp, u32 features)
> +{
> + bool was = dp->user_features & OVS_DP_F_TC_RECIRC_SHARING;
> + bool now = features & OVS_DP_F_TC_RECIRC_SHARING;
> +
> + if (now && !was)
> + tc_skb_ext_tc_enable();
> + else if (!now && was)
> + tc_skb_ext_tc_disable();
> +
> + dp->user_features = features;
> +}
> +
[ ... ]
> @@ -1961,8 +1970,7 @@ static void __dp_destroy(struct datapath *dp)
> struct flow_table *table = &dp->table;
> int i;
>
> - if (dp->user_features & OVS_DP_F_TC_RECIRC_SHARING)
> - tc_skb_ext_tc_disable();
> + ovs_dp_set_user_features(dp, 0);
[Severity: High]
Can this early clear of dp->user_features race with upcalls that are still
in flight?
Before this patch, __dp_destroy() only dropped the tc reference. Now
ovs_dp_set_user_features() does a plain store of 0 to the whole bitmap, so
OVS_DP_F_UNALIGNED, OVS_DP_F_DISPATCH_UPCALL_PER_CPU and the other bits are
cleared too, not only OVS_DP_F_TC_RECIRC_SHARING.
When this store runs, every vport is still attached, the datapath is still
on ovs_net->dps, and call_rcu() has not run yet. Softirq readers on other
CPUs can still be inside queue_userspace_packet() for this dp, and that
function reads the field twice:
net/openvswitch/datapath.c:queue_userspace_packet() {
...
if (dp->user_features & OVS_DP_F_UNALIGNED)
hlen = min(skb_zerocopy_headlen(skb), cutlen);
...
skb_zerocopy() /* user_skb gets page frags, now nonlinear */
...
pad_packet(dp, user_skb);
}
net/openvswitch/datapath.c:pad_packet() {
if (!(dp->user_features & OVS_DP_F_UNALIGNED)) {
size_t plen = NLA_ALIGN(skb->len) - skb->len;
if (plen > 0)
skb_put_zero(skb, plen);
...
}
Say __dp_destroy() stores 0 between these two reads. Could pad_packet()
then call skb_put_zero() on the nonlinear user_skb and hit
SKB_LINEAR_ASSERT() in skb_put()?
plen is nonzero whenever the packet length is not a multiple of 4.
ovs-vswitchd always sets OVS_DP_F_UNALIGNED. So it looks like deleting a
datapath under traffic (OVS_DP_CMD_DEL, vswitchd teardown, or
ovs_exit_net()) is enough to open this window. That needs only
CAP_NET_ADMIN in the owning user namespace.
The same clear also changes in-flight upcalls in ovs_dp_process_packet()
and output_userspace(). During teardown they fall back from per-CPU
dispatch to per-vport portid selection.
The new kernel-doc in datapath.h says:
so this field is written last, through
ovs_dp_set_user_features(), with ovs_mutex held.
Here, though, __dp_destroy() writes the field first, before any vport is
detached.
The datapath is only freed after an RCU grace period. As far as I can
tell, no fast-path code reads OVS_DP_F_TC_RECIRC_SHARING per dp; flow.c
checks tc_skb_ext_tc_enabled(). Would it be enough for __dp_destroy() to
keep the old conditional tc_skb_ext_tc_disable()? Or it could call
something like:
ovs_dp_set_user_features(dp, dp->user_features &
~OVS_DP_F_TC_RECIRC_SHARING);
The same bit could already be flipped racily through OVS_DP_CMD_SET and
ovs_dp_reset_user_features() before this patch. Closing that older variant
would also need queue_userspace_packet() to take one READ_ONCE() snapshot,
pass it to pad_packet(), and use WRITE_ONCE() in the setter.
The only later patch in the series, "selftests/net/openvswitch: check that
a failed set keeps the features", does not touch net/. So this is still
present at the end of the series.
>
> for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
> struct vport *vport;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115163134.3202677-1-houminxi%40gmail.com
next prev parent reply other threads:[~2026-11-16 16:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 16:31 [PATCH net v4 0/2] net: openvswitch: fix a feature leak on a failed change Minxi Hou
2026-11-15 16:31 ` [PATCH net v4 1/2] net: openvswitch: do not record user features when the change fails Minxi Hou
2026-11-16 16:33 ` netdev-bot+sashiko [this message]
2026-11-15 16:31 ` [PATCH net v4 2/2] selftests/net/openvswitch: check that a failed set keeps the features Minxi Hou
2026-11-16 16:33 ` netdev-bot+sashiko
2026-11-15 20:12 ` [PATCH net v4 0/2] net: openvswitch: fix a feature leak on a failed change netdev-bot+sinfo
2026-11-16 1:32 ` Minxi Hou
2026-11-16 11:58 ` Matthieu Baerts
2026-11-16 12:32 ` 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=179484682026.3136.13753538826492049125@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aconole@redhat.com \
--cc=echaudro@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=houminxi@gmail.com \
--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 \
/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