From: Minxi Hou <houminxi@gmail.com>
To: netdev@vger.kernel.org
Cc: dev@openvswitch.org, aconole@redhat.com, echaudro@redhat.com,
i.maximets@ovn.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
matttbe@kernel.org, shuah@kernel.org,
netdev-bot+sashiko@kernel.org, Minxi Hou <houminxi@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH net v6 1/3] net: openvswitch: read the datapath features once when sending an upcall
Date: Tue, 24 Nov 2026 09:50:31 -0500 [thread overview]
Message-ID: <20261124145033.627044-2-houminxi@gmail.com> (raw)
In-Reply-To: <20261124145033.627044-1-houminxi@gmail.com>
queue_userspace_packet() decides from OVS_DP_F_UNALIGNED whether to copy
the packet with skb_zerocopy(), and pad_packet() reads the same field
again after the copy. A concurrent OVS_DP_CMD_SET can clear the bit
between the two reads, so the copy leaves a nonlinear skb and the padding
calls skb_put_zero() on it. skb_put() asserts that the skb is linear, so
the kernel oopses, and a host built with panic_on_oops goes down.
OVS_DP_CMD_SET needs CAP_NET_ADMIN, which a user namespace that owns a
network namespace provides, so the window is reachable without
privileges on the host.
Read the field once and pass that value to pad_packet().
Fixes: aea0bb4f8ee5 ("openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed")
Cc: stable@vger.kernel.org
Signed-off-by: Minxi Hou <houminxi@gmail.com>
---
v6: split out of the fix v5 carried as one patch. Reading the field
once is an older and separate crash, so it stands as its own patch
with its own Fixes: tag (aea0bb4f8ee5, the commit that added the
second read).
net/openvswitch/datapath.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index b2a0b09fd4a5..96baa2488c26 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -439,9 +439,9 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
return size;
}
-static void pad_packet(struct datapath *dp, struct sk_buff *skb)
+static void pad_packet(struct sk_buff *skb, u32 features)
{
- if (!(dp->user_features & OVS_DP_F_UNALIGNED)) {
+ if (!(features & OVS_DP_F_UNALIGNED)) {
size_t plen = NLA_ALIGN(skb->len) - skb->len;
if (plen > 0)
@@ -461,6 +461,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
size_t msg_size;
size_t skb_len;
unsigned int hlen;
+ u32 features;
int err, dp_ifindex;
u64 hash;
@@ -494,11 +495,18 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
(err = skb_csum_hwoffload_help(skb, 0)))
goto out;
+ /* A concurrent change to the features can land between the head room
+ * decision below and the padding after the copy, which would pad a
+ * nonlinear skb and trip SKB_LINEAR_ASSERT. Read the field once and use
+ * that value for both.
+ */
+ features = READ_ONCE(dp->user_features);
+
/* Older versions of OVS user space enforce alignment of the last
* Netlink attribute to NLA_ALIGNTO which would require extensive
* padding logic. Only perform zerocopy if padding is not required.
*/
- if (dp->user_features & OVS_DP_F_UNALIGNED)
+ if (features & OVS_DP_F_UNALIGNED)
hlen = min(skb_zerocopy_headlen(skb), cutlen);
else
hlen = skb_len;
@@ -598,7 +606,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
goto out;
/* Pad OVS_PACKET_ATTR_PACKET if linear copy was performed */
- pad_packet(dp, user_skb);
+ pad_packet(user_skb, features);
((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len;
--
2.56.1
next prev parent reply other threads:[~2026-11-24 14:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:50 [PATCH net v6 0/3] net: openvswitch: fix a feature leak on a failed change Minxi Hou
2026-11-24 14:50 ` Minxi Hou [this message]
2026-11-24 14:50 ` [PATCH net v6 2/3] net: openvswitch: do not record user features when the change fails Minxi Hou
2026-11-24 14:50 ` [PATCH net v6 3/3] selftests/net/openvswitch: check that a failed set keeps the features Minxi Hou
2026-11-24 14:52 ` [PATCH net v6 0/3] net: openvswitch: fix a feature leak on a failed change netdev-bot+sinfo
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=20261124145033.627044-2-houminxi@gmail.com \
--to=houminxi@gmail.com \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=echaudro@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kuba@kernel.org \
--cc=matttbe@kernel.org \
--cc=netdev-bot+sashiko@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