Netdev List
 help / color / mirror / Atom feed
* [PATCH net 1/2] bonding: reject frames with insufficient headroom in bond_header_create
@ 2026-08-24  2:18 Qihang
  2026-08-24  2:18 ` [PATCH net 2/2] team: reject frames with insufficient headroom in team_header_create Qihang
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Qihang @ 2026-08-24  2:18 UTC (permalink / raw)
  To: jv, jiri
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, willemb, netdev,
	Qihang Tang, stable

From: Qihang Tang <q.h.hack.winter@gmail.com>

AF_PACKET SOCK_DGRAM sends reserve skb headroom from a snapshot of
bond_dev->hard_header_len.  A concurrent bond type change can switch the
active slave to one with a larger hard_header_len between that snapshot
and bond_header_create(), so the slave's create() pushes or writes past
skb->head.

The hard_header_len snapshot series that fixed the SOCK_RAW send paths
deferred this SOCK_DGRAM race: dev->header_ops is the stable
bond_header_ops, so snapshotting header_ops in the caller does not help.

Reject the frame if skb headroom is smaller than the active slave's
hard_header_len, before delegating under the existing rcu_read_lock.

Fixes: 950803f72547 ("bonding: fix type confusion in bond_setup_by_slave()")
Cc: stable@vger.kernel.org
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Qihang Tang <q.h.hack.winter@gmail.com>
---
 drivers/net/bonding/bond_main.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 522eab060f9e..9ec663610dfd 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1524,10 +1524,24 @@ static int bond_header_create(struct sk_buff *skb, struct net_device *bond_dev,
 	slave = rcu_dereference(bond->curr_active_slave);
 	if (slave) {
 		slave_ops = READ_ONCE(slave->dev->header_ops);
-		if (slave_ops && slave_ops->create)
+		if (slave_ops && slave_ops->create) {
+			unsigned int hlen = READ_ONCE(slave->dev->hard_header_len);
+
+			/* Headroom was reserved from a snapshot of
+			 * bond_dev->hard_header_len that may predate this
+			 * slave (concurrent bond type change); reject if
+			 * insufficient for the slave's create(), which
+			 * pushes its own hlen.
+			 */
+			if (skb_headroom(skb) < hlen) {
+				ret = -EINVAL;
+				goto unlock;
+			}
 			ret = slave_ops->create(skb, slave->dev,
 						type, daddr, saddr, len);
+		}
 	}
+unlock:
 	rcu_read_unlock();
 	return ret;
 }
-- 
2.50.1 (Apple Git-155)


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

end of thread, other threads:[~2026-08-28  6:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH net 2/2] team: reject frames with insufficient headroom in team_header_create Qihang
2026-08-26  2:02 ` [PATCH net 1/2] bonding: reject frames with insufficient headroom in bond_header_create 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

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