From: Qihang <q.h.hack.winter@gmail.com>
To: jv@jvosburgh.net, jiri@resnulli.us
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
netdev@vger.kernel.org, Qihang Tang <q.h.hack.winter@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH net 2/2] team: reject frames with insufficient headroom in team_header_create
Date: Mon, 24 Aug 2026 10:18:02 +0800 [thread overview]
Message-ID: <20260824021802.90369-2-q.h.hack.winter@gmail.com> (raw)
In-Reply-To: <20260824021802.90369-1-q.h.hack.winter@gmail.com>
From: Qihang Tang <q.h.hack.winter@gmail.com>
AF_PACKET SOCK_DGRAM sends reserve skb headroom from a snapshot of
team_dev->hard_header_len. A concurrent team type change can switch the
selected port to one with a larger hard_header_len between that snapshot
and team_header_create(), so the port's create() pushes or writes past
skb->head.
This is the same race as in bond_header_create(); the snapshot series
that fixed the SOCK_RAW send paths deferred it. dev->header_ops is the
stable team_header_ops, so snapshotting header_ops in the caller does
not help.
Reject the frame if skb headroom is smaller than the selected port's
hard_header_len, before delegating under the existing rcu_read_lock.
Fixes: 425000dbf173 ("team: fix header_ops type confusion with non-Ethernet ports")
Cc: stable@vger.kernel.org
Cc: Willem de Bruijn <willemb@google.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Qihang Tang <q.h.hack.winter@gmail.com>
---
drivers/net/team/team_core.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index feaa75fbf8fc..2742a4bfc9d0 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -2269,10 +2269,24 @@ static int team_header_create(struct sk_buff *skb, struct net_device *team_dev,
port = team_header_port_get_rcu(team, true);
if (port) {
port_ops = READ_ONCE(port->dev->header_ops);
- if (port_ops && port_ops->create)
+ if (port_ops && port_ops->create) {
+ unsigned int hlen = READ_ONCE(port->dev->hard_header_len);
+
+ /* Headroom was reserved from a snapshot of
+ * team_dev->hard_header_len that may predate this
+ * port (concurrent team type change); reject if
+ * insufficient for the port's create(), which
+ * pushes its own hlen.
+ */
+ if (skb_headroom(skb) < hlen) {
+ ret = -EINVAL;
+ goto unlock;
+ }
ret = port_ops->create(skb, port->dev,
type, daddr, saddr, len);
+ }
}
+unlock:
rcu_read_unlock();
return ret;
}
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-08-24 2:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 2:18 [PATCH net 1/2] bonding: reject frames with insufficient headroom in bond_header_create Qihang
2026-08-24 2:18 ` Qihang [this message]
2026-08-26 2:02 ` Willem de Bruijn
2026-08-27 3:13 ` Qihang
2026-08-27 5:10 ` Jiayuan Chen
2026-08-27 21:37 ` Willem de Bruijn
2026-08-28 1:12 ` Hangbin Liu
2026-08-28 2:43 ` Willem de Bruijn
2026-08-28 6:07 ` Qihang
2026-08-27 1:10 ` Hangbin Liu
2026-08-27 3:25 ` Qihang
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=20260824021802.90369-2-q.h.hack.winter@gmail.com \
--to=q.h.hack.winter@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=willemb@google.com \
/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